This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aalbrecht
Recipients
Date 2007-08-17.08:18:29
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
The problem occurs, when you are using strings, not when you use
the Header class directly.
The reason for this behaviour is the way the Generator creates
Header instances from strings: It initializes the class with
continuation_ws set to '\t' instead of the default ' ' 
(email/generator.py in method _write_headers).

>>> from email.MIMEText import MIMEText
>>> msg = MIMEText("Just a test.")
>>> msg["Subject"] = "foo "*22
>>> print msg.as_string()
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
        foo foo foo foo foo 

Just a test.
>>> 

Tab as the whitespace character is no problem for most email clients. But
i.e. Outlook removes it.

When using the Header class you get the following

>>> from email.MIMEText import MIMEText
>>> from email.header import Header
>>> msg = MIMEText("Just a test.")
>>> msg["Subject"] = Header("foo "*22)
>>> print msg.as_string()
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
 foo foo foo 

Just a test.
>>> 

The last message shows up in Outlook correctly.
History
Date User Action Args
2007-08-23 14:51:34adminlinkissue1645148 messages
2007-08-23 14:51:34admincreate