email - Missing headers when sending mail from python -


i'm having weird problem sending out e-mail python script.

this 1 works perfectly:

msg = mimetext(body) msg['subject'] = 'booking confirmation %s, %s.'% (tourname, tourdatetime.strftime('%d %b %y, %h:%m')) msg['from'] = fromaddress msg['to'] = email msg['cc'] = owneraddress s = smtplib.smtp(mailserver) s.sendmail(fromaddress, [email, owneraddress], msg.as_string()) s.quit() 

the received e-mail looks expect to.

from same server, following snippet doesn't work properly: e-mail sent out correct recipients, attachment there, to: , cc: headers missing mail that's been received. subject, body , from: set correctly.

msg = mimemultipart() msg['subject'] = subject msg['from'] = fromaddress msg['to'] = data['email'] msg['cc'] = owneraddress msg.attach(mimetext(body)) part = mimebase('application', "octet-stream") part.set_payload(     file(         os.path.join(             directory, '../images', 'meetingpoint_%s.jpg'% (data['tourid'], ))         ).read()) encoders.encode_base64(part) part.add_header('content-disposition', 'attachment; filename="%s"' % ('meetingpoint_%s.jpg'% (data['tourid'], ), )) msg.attach(part) smtp.sendmail(fromaddress, [data['email'], owneraddress], msg.as_string()) 


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -