python - Amazon SES Friendly From Header -


i'm having trouble getting amazon ses display friendly header. issue seems ses inserting additional header before mine.

i'm using python boto, , sending mime message using send_raw_email method.

to_str = 'name <name@domain.com>' from_str = 'name2 <name2@domain.com>' msg = mimemultipart('alternative') msg['subject'] = 'hello world' msg['from'] = from_str msg['to'] = to_str msg.attach(mimetext(em_plain, 'plain')) msg.attach(mimetext(em_html, 'html')) ses_connection.send_raw_email(msg.as_string(), source=from_str, destinations=to_str) 

what in headers of message that's delivered looks this:

subject: hello world date: thu, 9 apr 2015 20:47:31 +0000 message-id: <blah-blah-blah@email.amazonses.com> from: name2@domain.com x-ses-outgoing: 2015.blah.blah feedback-id: 1.us-east-1.blah//blah=:amazonses  from: "name2" <name2@domain.com> to: "name" <name@domain.com> 

the result user's mailbox not display friendly name. plenty of info on web says possible, can't working.

looking further, if omit optional source parameter on call send_raw_email, call fails error missing header ... despite fact has been set within mimemultipart object.

so, think there 2 issues - first, if pass friendly header in source parameter, gets stripped down email address. second, that's in mimemultipart isn't recognized.

figured out.

order of operations on mimemultipart object matters.

you have set header first, to, subject.

if in order, can safely leave out optional source , destination parameters on send_raw_email call.

would seem limitation/issue ses, many other mail servers not require header come before subject.


Popular posts from this blog