AWS SES 中的电子邮件问题



>我已经在SES控制台中配置了电子邮件ID和域,并验证了它们中的每一个。我选择的地区是欧盟爱尔兰。

使用SES控制台,我可以向已验证的ID发送测试邮件。

但是,我在使用 lambda 代码发送邮件时遇到问题。

这是一段让我发疯的代码:

var aws = require("aws-sdk");
var nodemailer = require("nodemailer");
aws.config.update({
  accessKeyId: "myaccesskey",
  secretAccessKey: "mysecretkey",
  region: "us-west-2"
});
var ses = new aws.SES();

exports.handler = function (event, context, callback) {
    var mailOptions = {
        from: "myverifiedemailaddess@domain.com",
        subject: "This is an email sent from a Lambda function!",
        html: `<p>You got a contact message from: </b></p>`,
        to: "myverifiedemailaddess@domain.com",
        // bcc: Any BCC address you want here in an array,
    };
    // create Nodemailer SES transporter
    var transporter = nodemailer.createTransport({
        SES: ses
    });
    // send email
    transporter.sendMail(mailOptions, function (err, info) {
        if (err) {
            console.log("Error sending email");
            callback(err);
        } else {
            console.log("Email sent successfully");
            callback();
        }
    });
};

每次我使用代码发送和发送电子邮件时,我都会收到以下错误:

{
  "errorMessage": "Email address is not verified. The following identities failed the check in region US-WEST-2: myverifiedemailaddess@domain.com",
  "errorType": "MessageRejected",
  "stackTrace": [
    "Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/query.js:50:29)",
    "Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
    "Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
    "Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)",
    "Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)",
    "AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)",
    "/var/task/node_modules/aws-sdk/lib/state_machine.js:26:10",
    "Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)",
    "Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:685:12)",
    "Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:116:18)"
  ]
}
您需要

在同一区域中具有SESLambda才能工作,

请阅读此内容,

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/regions.html#region-receive-email

相关内容

  • 没有找到相关文章

最新更新