[英]How to dynamically set aws ses TemplateData using node.js?
I'm trying to send an email with custom data.我正在尝试发送带有自定义数据的 email。
async function sendEmailToSalesTeamOnBookingDemoClass(email,name,phoneNumber,utmSource,utmTerm,utmMedium,deviceType,browser,referrer) {
try {
let emailMe = "abc@gmail.com"
const ses = new AWS.SES({ apiVersion: "2010-12-01" });
const params = {
Destination: {
ToAddresses: [emailMe]
},
Source: senderEmail,
Template: "Sales_Email_Demo",
TemplateData : JSON.stringify({
"name": name,
"email": email,
"phone": phoneNumber,
"utmSource":utmSource,
"utmTerm":utmTerm,
"utmMedium":utmMedium,
"browser":browser,
"referrer":referrer,
"deviceType":deviceType
}),
Tags: [
{
Name: 'SomeName',
Value: 'info'
}
]
};
const sendEmailReceiver = ses.sendTemplatedEmail(params).promise();
sendEmailReceiver
.then(data => {
console.log(senderEmail,emailMe)
console.log("Email submitted to SES", data);
})
.catch(error => {
console.log("Email not submitted to SES:" + error);
});
}
catch (e) {
console.error(`Error: ${e}`);
}
}
The response says that the email was sent successfully.响应说 email 已成功发送。
Email submitted to SES {
ResponseMetadata: { RequestId: 'c08b9948-7be3-465d-a72c-fcca23f9f059' },
MessageId: '010901793bd95a02-813072dc-bb87-4b65-91c4-03f7f29dcbd0-000000'
}
But there is no email received even though the sender email has been verified and tested.但是,即使发送方 email 已经过验证和测试,也没有收到 email。 Is there something wrong with my template?
我的模板有问题吗?
{
"Template": {
"TemplateName": "Sales_Email_Demo",
"SubjectPart": "some subject!",
"HtmlPart": "<html> <body><p>Hello,</p><p>Details:</p><p>Name:{{name}}</p><p>Phone Number: {{phoneNumber}}</p><p>Email Id: {{emailId}}</p><p>Source: {{utmSource}}</p><p>Medium: {{utmMedium}}</p><p>Term:{{utmTerm}}</p><p>Device:{{deviceType}}</p><p>Browser:{{browser}}</p><p>Referrer: {{referrer}}</p></body></html>"
}
}
I figured it out.我想到了。 The issue was with the template.
问题出在模板上。 The sending and receiving variables were named differently.
发送和接收变量的名称不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.