Sending aws cli SES as a file attachmennt

人走茶凉 提交于 2019-12-11 16:59:25

问题


I am trying to send my file as an attachment in my AWS SES via AWS CLI. Given below is the message.json sample provided by aws documentation

{
   "Data": "From: sender@example.com\nTo: recipient@example.com\nSubject: Test email sent using the AWS CLI (contains an attachment)\nMIME-Version: 1.0\nContent-type: Multipart/Mixed; boundary=\"NextPart\"\n\n--NextPart\nContent-Type: text/plain\n\nThis is the message body.\n\n--NextPart\nContent-Type: text/plain;\nContent-Disposition: attachment; filename=\"attachment.txt\"\n\nThis is the text in the attachment.\n\n--NextPart--"
}

Where do I add path of the attachment file needed to this json Can anybody help?

Thanks in advance


回答1:


You need to encode the attachment file to Base64 and use it in the json body.

Example:

Content-Type: application/pdf; name="filename.extension" Content-Description: filename.extension Content-Disposition: attachment; filename="filename.ext"; Content-Transfer-Encoding: base64

\n\nbase-64-text-body\n\n--

You can use Python or node.js code to convert it automatically for you.



来源:https://stackoverflow.com/questions/54949727/sending-aws-cli-ses-as-a-file-attachmennt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!