Problem with exchange mail server

V

Vinayakc

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top