Email problem
Josiah Carlson
jcarlson at uci.edu
Thu Oct 14 20:26:26 EDT 2004
> Ok, I'm putting my email message together this way:
> for x in M.retr(i)[1]:
> stringMail += x
> stringMail += '\n'
> inMail = email.message_from_string(stringMail)
> What I'm finding is in the html part of the message '='s are added to the end
> of lines that don't end in a tag which is completely messing up the display in
> my WxHTMLWindow I use to display messages. Any thoughts?
One thing you should always do when creating email is making sure that
lines end with a CRLF pair. Lines that only end with one or the other
but not both are not RFC 2822 compliant. It may be the case that the '='
are added to lines that are ended improperly.
To fit in with what you are doing above:
stringMail += x.rstrip() + '\r\n'
Though I would suggest against the generally slow repeated string
concatenation (for large numbers of concatenations), replacing it with:
mail = []
for x in M.retr(i)[1]:
mail.append(x.rstrip())
inMail = email.message_from_string('\r\n'.join(mail))
Try that out and see how it works.
- Josiah
More information about the Python-list
mailing list