Problem with exchange mail server

Vinayakc vinayakchitre at gmail.com
Mon Nov 28 10:19:25 EST 2005


I am new for python. I have written one code which generates RFC2822
file.
I have header in string format.

i am using following code.

emailData[SMTP_HEADER_POS] = emailData[SMTP_HEADER_POS].encode("utf-8")
hdr = email.message_from_string(emailData[SMTP_HEADER_POS])
tmpContentType = msg['Content-Type']
        del msg['Content-Type']

        for key in hdr.keys():
        	values = hdr.get_all(key)
        	if values != None:
        		if key not in msg:
        			for value in values:
        				msg.add_header(key,value)

        if msg['Content-Type'] is None or msg['Content-Type'] == '':
            msg['Content-Type'] = tmpContentType

is this right way to add the header??

This code is not doing well for exchange server mails. Python could not
parse this mail header. Because first line is 'Microsoft exchange mail
server version 2.0'.
If I remove this line, it works. Could not understand this. Please
help.

Thanks and Regards
Vinayakc




More information about the Python-list mailing list