message returned by poplib to email.Messge instance
Aaron Sterling
dhaaron at hotpop.com
Thu Nov 29 01:32:27 EST 2001
Hi,
The poplib.POP3.retr() method returns a tuple (size_string, content_list, size_int). The email package provides a
function message_from_string(string) that returns an object tree describing the string as an rfc2822 message. My
problem is in how to convert content_list into a string that message_from_string will recognize as a multipart
message. What I have so far is
msg = email.message_from_string('\n'.join(content_list))
this executes without error. It is a message object but:
>>> msg.is_multipart()
0
I know it is a properly formatted message, because I made it myself, using email package, and check its validity by:
>>> message.is_multipart()
1
as well as succesfully extracting all of the information I need to from it. I send it over the internet with smtplib. I send it
directly to my isp's smtp server, as i believe smtplib is supposed to be used.
to do this I use smtplib.SMTP.sendmail(fromaddr, toaddr, str(message))
I am fairly sure that stringing the message is not causing the problem, as smtplib requires a string and:
>>> message = email.message_from_string(str(message))
>>> message.is_multipart()
1
any light that could be shed on the issue would be greatly appreciated.
Thanks,
---------------------------------------------------------------------------
Aaron, dhaaron at hotpop.com
"In this time of war against Osama Bin Laden and the oppressive Taliban regime, we are thankful that *our* leader
isn't the spoiled son of a powerful politician from a wealthy oil family who is supported by religous fundamentalists,
operates through clandestine organizations, has no respect for the democratic electoral process, bombs innocents,
and uses war to deny people their civil liberties" -unknown
More information about the Python-list
mailing list