我正在尝试使用ses在typescript中设置电子邮件服务。我遵循了这个示例https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/javascript/example_code/ses/ses_sendemail.js,但我得到
AWS.ses 不是构造函数。
下面是我的emailService类
const AWS = require("aws-sdk");
const loggerService: LoggerServiceInterface = new LoggerService();
AWS.config.update({region: "us-east-1"});
export class EmailService {
sendEmail(recipient: string): Promise<boolean> {
const params = {
Destination: { /* required */
CcAddresses: [
"abcd@gmail.com",
/* more items */
],
ToAddresses: [
"abcd@gmail.com",
/* more items */
]
},
Message: { /* required */
Body: { /* required */
Html: {
Charset: "UTF-8",
Data: "HTML_FORMAT_BODY"
},
Text: {
Charset: "UTF-8",
Data: "TEXT_FORMAT_BODY"
}
},
Subject: {
Charset: "UTF-8",
Data: "Test email"
}
},
Source: "xyxy@gmail.com",
ReplyToAddresses: [
"xyxy@gmail.com",
],
};
const sendPromise = new AWS.SES({apiVersion: "2010-12-01"}).sendEmail(params).promise();
sendPromise.then(function(data) {
console.log(data.MessageId);
}).catch(
function(err) {
console.error(err, err.stack);
});
return Promise.resolve(true);
}
}
我在一个sanbox环境中,这两封邮件都经过了验证。我是不是漏掉了什么?
3条答案
按热度按时间bvhaajcl1#
这对我有用
bd1hkmkf2#
使用异步lambda函数和AWS-SDK SES with promises:
xvw2m8pv3#
使用AWS SDK v-3: