无服务器电子邮件附件
Serverless Email Attachment
我是无服务器和 AWS 的初学者。我实际上陷入困境。通过无服务器发送电子邮件时,我想附加一个文件。事实上,我找不到任何完美的文章或文档来满足我的要求。
我做的是
JS 文件。
exports.sendMail = async(event) =>{
var data = {
Destination: {
ToAddresses: [
"******.@gmail.com"
]
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: "This message body contains HTML formatting. It can, for example, contain links like this one: <a class=\"ulink\" href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide\" target=\"_blank\">Amazon SES Developer Guide</a>."
},
Text: {
Charset: "UTF-8",
Data: "This is the message body in text format."
}
},
Subject: {
Charset: "UTF-8",
Data: "Test email"
}
},
Source: "********.com",
}
try {
const sendPromise = await new AWS.SES({ apiVersion: "2010-12-01" })
.sendEmail(data)
.promise();
return{
statusCode: 200,
body: JSON.stringify(sendPromise)
}
}catch (err){
return {
statusCode: err.statusCode || 400,
body: err.message || JSON.stringify(err.message)
}
}
}
我做的是发送是发送邮件。这按预期工作。但是不知道在哪里插入附件部分。
非常感谢任何帮助或建议。
提前致谢
您必须使用 SES.sendRawEmail() API in order to send email with attachments. There are a few examples in the SES Developer guide how this can be implemented in various programming languages (currently Java, PHP, Python and Ruby). Please also read the Sending Raw Email 章节获取一般信息。
我是无服务器和 AWS 的初学者。我实际上陷入困境。通过无服务器发送电子邮件时,我想附加一个文件。事实上,我找不到任何完美的文章或文档来满足我的要求。
我做的是
JS 文件。
exports.sendMail = async(event) =>{
var data = {
Destination: {
ToAddresses: [
"******.@gmail.com"
]
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: "This message body contains HTML formatting. It can, for example, contain links like this one: <a class=\"ulink\" href=\"http://docs.aws.amazon.com/ses/latest/DeveloperGuide\" target=\"_blank\">Amazon SES Developer Guide</a>."
},
Text: {
Charset: "UTF-8",
Data: "This is the message body in text format."
}
},
Subject: {
Charset: "UTF-8",
Data: "Test email"
}
},
Source: "********.com",
}
try {
const sendPromise = await new AWS.SES({ apiVersion: "2010-12-01" })
.sendEmail(data)
.promise();
return{
statusCode: 200,
body: JSON.stringify(sendPromise)
}
}catch (err){
return {
statusCode: err.statusCode || 400,
body: err.message || JSON.stringify(err.message)
}
}
}
我做的是发送是发送邮件。这按预期工作。但是不知道在哪里插入附件部分。
非常感谢任何帮助或建议。
提前致谢
您必须使用 SES.sendRawEmail() API in order to send email with attachments. There are a few examples in the SES Developer guide how this can be implemented in various programming languages (currently Java, PHP, Python and Ruby). Please also read the Sending Raw Email 章节获取一般信息。