Reputation: 13
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: [email protected]\nTo: [email protected]\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
Upvotes: 1
Views: 4148
Reputation: 4421
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.
Upvotes: 3