You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the value of the "From:" header (display name + email address) becomes too long (more than 72 characters) repoze.sendmail will generate a "From:" string which contains a newline (\n).
("From: " is 6 characters long, default line length is 78 chars in Python's email module)
This seems to be ok when using the regular email.message.Message class (Python 2+3). However I'm using Python 3's email.message.EmailMessage class (as I like its API more). In that case I get the following error message (Python 3.4 and 3.6, no other versions tested):
Traceback (most recent call last):
File "repsendmail.py", line 26, in <module>
result = delivery.send('[email protected]', '[email protected]', msg)
File "…/repoze/sendmail/delivery.py", line 204, in send
encoding.cleanup_message(message)
File "…/repoze/sendmail/encoding.py", line 70, in cleanup_message
message.replace_header(key, value)
File "/usr/lib64/python3.6/email/message.py", line 555, in replace_header
self._headers[i] = self.policy.header_store_parse(k, _value)
File "/usr/lib64/python3.6/email/policy.py", line 145, in header_store_parse
raise ValueError("Header values may not contain linefeed "
ValueError: Header values may not contain linefeed or carriage return characters
It seems to me that calling Header.encode() is not really correct when you want to put the resulting value back in the EmailMessage instance.
Attached is a self-contained Python script which demonstrates the issue: repsendmail.py.txt (with .txt extension because github does not like .py files).
The text was updated successfully, but these errors were encountered:
When the value of the "From:" header (display name + email address) becomes too long (more than 72 characters) repoze.sendmail will generate a "From:" string which contains a newline (
\n
).("From: " is 6 characters long, default line length is 78 chars in Python's email module)
This seems to be ok when using the regular
email.message.Message
class (Python 2+3). However I'm using Python 3'semail.message.EmailMessage
class (as I like its API more). In that case I get the following error message (Python 3.4 and 3.6, no other versions tested):It seems to me that calling
Header.encode()
is not really correct when you want to put the resulting value back in theEmailMessage
instance.Attached is a self-contained Python script which demonstrates the issue:
repsendmail.py.txt (with
.txt
extension because github does not like.py
files).The text was updated successfully, but these errors were encountered: