How can I send an image attachment using boto3 SES send_email client?
I know that I can use send_raw_email to send an attachment but I need to send the message body with html data. If this is not possible, how can I send an email with html data using boto3.ses.send_raw_email() ?
Shameless copy example from "HOW TO SEND HTML MAILS USING AMAZON SES " This is how a typical email data content looks like.
message_dict = { 'Data':
'From: ' + mail_sender + '\n'
'To: ' + mail_receivers_list + '\n'
'Subject: ' + mail_subject + '\n'
'MIME-Version: 1.0\n'
'Content-Type: text/html;\n\n' +
mail_content}
If you want to send attachment and HTML text using boto3.ses.send_raw_email, you just need use above message dict and pass. (just put your html text under the mail_content)
response = client.send_raw_email(
Destinations=[
],
FromArn='',
RawMessage=message_dict,
ReturnPathArn='',
Source='',
SourceArn='',
)
In fact, the raw attachment header should works in both send_email() and send_raw_email() . Except in send_mail, you should put the attachment inside Text, not html.
所有评论(0)