Commit 4dca9600 authored by Raphaël Hertzog's avatar Raphaël Hertzog

mail: rely on EmailValidator instead of our own custom validation code

parent d7c887fe
......@@ -13,9 +13,10 @@ commands.
import re
from email.utils import parseaddr
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.validators import EmailValidator
......@@ -161,11 +162,9 @@ class Command(metaclass=MetaCommand):
def validate_email(email):
_, sane_email = parseaddr(email)
if sane_email != email:
validate = EmailValidator()
return True
except ValidationError:
return False
if not re.match(r'[^@\s]+@[^@\s]+\.[^@\s]+$', email):
return False
return True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment