Can not always convert email to ASCII
If the locale part of the email is not ASCII, email_validator does fill ascii_email
with None
.
So this crashes email.utils.formataddr
because it is expecting strings.
Instead we should fallback to the normalized email in this case. If the email server supports SMTPUTF8
, it could still be sent.
Also email.utils.formataddr
supports only ASCII addresses but indeed the norm requires only the domain part to be ASCII with RFC 6530. So we should have our own version of formataddr that does not enforce ASCII. At worse the it is the smtplib that will raise an error because the mail server does not support SMTPUTF8.
We will see if Python accepts to remove the constraint: https://github.com/python/cpython/issues/118716