mailer icon indicating copy to clipboard operation
mailer copied to clipboard

Comma in Email Address Name

Open nashley opened this issue 7 years ago • 0 comments

Commas in the name in an email address cause the address parser to parse the address as multiple addresses and therefore fail.

Take the following address for example:
"Bond, James" <[email protected]> It should have Bond, James as the name and [email protected] as the email, but instead it tries to parse Bond as an email address and fails.

Here's a traceback:

Traceback (most recent call last):
  File "__main__.py", line 136, in <module>
    main()
  File "__main__.py", line 126, in main
    download_calendars()
  File "__main__.py", line 111, in download_calendars
    sender='[email protected]'
  File "/usr/local/lib/python3.6/site-packages/marrow/mailer/message.py", line 79, in __init__
    self.author = author
  File "/usr/local/lib/python3.6/site-packages/marrow/mailer/message.py", line 95, in __setattr__
    object.__setattr__(self, name, value)
  File "/usr/local/lib/python3.6/site-packages/marrow/mailer/address.py", line 222, in __set__
    value = self.cls(value)
  File "/usr/local/lib/python3.6/site-packages/marrow/mailer/address.py", line 145, in __init__
    self.extend(addresses)
  File "/usr/local/lib/python3.6/site-packages/marrow/mailer/address.py", line 182, in extend
    values = [Address(val) if not isinstance(val, Address) else val for val in sequence]
  File "/usr/local/lib/python3.6/site-packages/marrow/mailer/address.py", line 182, in <listcomp>
    values = [Address(val) if not isinstance(val, Address) else val for val in sequence]
  File "/usr/local/lib/python3.6/site-packages/marrow/mailer/address.py", line 58, in __init__
    raise ValueError('"{0}" is not a valid e-mail address: {1}'.format(email, err))
ValueError: "Bond" is not a valid e-mail address: An email address must contain a single @

This behavior is only expected if the name is not encapsulated with quotes.

nashley avatar Jul 17 '17 18:07 nashley