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.

classification
Title: imaplib should convert line endings to be rfc2822 complient
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pierslauder Nosy List: anadelonbrin, anthonybaxter, mwh, pierslauder
Priority: normal Keywords:

Created on 2003-04-19 00:16 by anadelonbrin, last changed 2022-04-10 16:08 by admin. This issue is now closed.

Messages (6)
msg15515 - (view) Author: Tony Meyer (anadelonbrin) Date: 2003-04-19 00:16
When imaplib.append is called, it should convert line 
endings from whatever they are (\r, \n or \r\n) to the 
format required by rfc2822 (in turn, required by rfc1730), 
i.e. CRLF - \r\n.

The email package generates mail with Python "internal" 
line endings (i.e. \n), and so if a message is flattened 
and then appended via imap improper line endings are 
sent.

While some imap servers are ok with this, at least one 
(Communigate Pro) mangles the message (all the 
headers become part of the body).

smtplib has an example of how to do this.
msg15516 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2003-04-19 12:55
Logged In: YES 
user_id=29957

You may want to contact imaplib's author, (Piers Lauder
<piers@cs.su.oz.au>)
directly about this.
msg15517 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-04-19 13:44
Logged In: YES 
user_id=6656

Or just assign it to him :-)
msg15518 - (view) Author: Piers Lauder (pierslauder) * (Python triager) Date: 2003-04-29 23:41
Logged In: YES 
user_id=196212

This is a bug. Can't think how it's managed to survive for
so long (there must be a lot of forgiving imap servers out
there). Anyway,
I've just checked in a fix (based on the smtplib code -
thanks for
the ref.)

And thanks for the bug report.
msg15519 - (view) Author: Tony Meyer (anadelonbrin) Date: 2003-04-29 23:48
Logged In: YES 
user_id=552329

By the way, since posting this there was some discussion 
about the re used in smtplib.  Tim Peters, Tim Stone and 
Skip Montareo eventually agreed (more or less) that
CRLF_RE = re.compile(r'\r\n|\r|\n')
was better than the one in smtplib.  (I really ought to suggest 
that to whoever maintains smtplib as well...)

But anyway, thanks for fixing it.  I must say that the imap 
servers I have access to are forgiving enough - but it only 
takes one...
msg15520 - (view) Author: Piers Lauder (pierslauder) * (Python triager) Date: 2003-04-30 00:02
Logged In: YES 
user_id=196212

Couldn't agree more :-)  Now uses the much simpler regex.
I'm also going to mark this bug as 'fixed"
History
Date User Action Args
2022-04-10 16:08:14adminsetgithub: 38332
2003-04-19 00:16:16anadelonbrincreate