将AWS CLI SES发送为文件附件 [英] Sending aws cli SES as a file attachmennt

查看:245
本文介绍了将AWS CLI SES发送为文件附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过AWS CLI将文件作为附件发送到AWS SES中. 下面给出的是aws文档提供的message.json示例

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--"
}

我在何处添加此json所需的附件文件的路径 有人可以帮忙吗?

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

预先感谢

推荐答案

您需要将附件文件编码为Base64,并在json正文中使用它.

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

示例:

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--

您可以使用Pythonnode.js代码为您自动进行转换.

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

这篇关于将AWS CLI SES发送为文件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆