节点AWS-SDK SES邮件发送验证失败
Node AWS-SDK SES email send verification fail
我正在使用 aws-sdk 和 Node 发送 AWS SES 电子邮件,并且我能够使用 AWS CLI 成功发送电子邮件。但是,由于某种原因,在我的 Node 脚本中,我的电子邮件验证失败。
代码如下:
const aws = require('aws-sdk')
const ses = new aws.SES()
const message = {
Destination: {
ToAddresses: ['example@example.com']
},
Message: {
Body: {
Text: {
Charset: 'UTF-8',
Data: 'Test body'
}
},
Subject: {
Charset: 'UTF-8',
Data: 'Test subject'
}
},
Source: 'example@example.com'
}
ses.sendEmail(message, function (err, data) {
if (err) console.log(err);
else console.log(data);
});
错误如下:
message: 'Email address is not verified. The following identities failed the check in region US-EAST-1: example@example.com',
code: 'MessageRejected',
time: 2017-12-15T15:37:26.312Z,
requestId: 'random-id',
statusCode: 400,
retryable: false,
retryDelay: 15.030260565173382
请帮忙!谢谢!
根据 AWS troubleshooting documentation:
Email address is not verified. The following identities failed the check in region (region): (identity1), (identity2), (identity3) — You are trying to send email from an email address or domain that you have not verified with Amazon SES. This error could apply to the "From", "Source", "Sender", or "Return-Path" address.
If your account is still in the sandbox, you also must verify every recipient email address except for the recipients provided by the Amazon SES mailbox simulator. If Amazon SES is not able to show all of the failed identities, the error message ends with an ellipsis.
Note: Amazon SES has endpoints in multiple AWS regions, and email address verification status is separate for each AWS region. You must complete the verification process for each sender in the AWS region(s) you want to use.
我强烈怀疑您的应用程序配置与您用于通过 CLI 成功发送测试电子邮件的配置不 100% 匹配。
检查以下配置:
- 'Source' 地址必须是 us-east-1 区域中经过 SES 验证的发件人。检查您希望从中发送电子邮件的源地址是否是您打算从中发送电子邮件的每个区域中经过验证的发件人。
- 如果启用 SES 沙盒模式,电子邮件收件人('ToAddresses' 值)也必须是 us-east-1 区域中经过 SES 验证的发件人。有关如何删除此限制的说明,请参阅“Moving Out of the Amazon SES Sandbox”。
- 确保您测试的所有客户端都在同一区域进行测试,因为每个区域的配置需要不同。错误消息提到应用程序试图在 us-east-1 中命中 SES,因此请使用
--region
选项再次在 us-east-1 区域中明确执行 CLI 测试。如果使用 CLI 默认区域,并且该区域恰好不是 us-east-1,则初始 CLI 测试可能存在缺陷。
- 如果以上所有内容看起来都正确,请仔细检查您的节点应用程序。确保 SES 客户端已针对您希望使用的区域进行配置,并且该客户端正确地将您希望发送给 SES 请求的电子邮件写入。
进一步阅读
这是我的代码,使用 node.js 以及 express、ejs 和 npm 包 node-ses
上面有解决方法,但是容易漏掉。这是第三部分,在 key 和 secret 之后,回调到 amazon - url 需要在那里并且需要为您的地区定制,在我的例子中是 eu-west-1,其他两个选择是我们-east-1 或 us-west-2.
在 IAM - 用户中找到了密钥和秘密。一旦您设置了具有编程访问权限和 AmazonSESFullAccess 权限的用户。 Select 您的用户,然后 select "Security credentials" 选项卡。向下移动并单击“创建访问密钥”。
您只能访问您的秘密密码一次。当您获得访问权限时,突出显示秘密密码,将其复制并与您的密钥一起粘贴到安全的地方。
您的发件人电子邮件必须与在 AWS SES 页面上注册的域相关。如果您不使用 Route 53 托管,您还需要在 AWS SES 页面上注册并验证电子邮件。
这是路由器代码:
app.post('/email', function(req, res) {
var ses = require('node-ses'),
client = ses.createClient({
key: 'xxx',
secret: 'xxx',
amazon: 'https://email.eu-west-1.amazonaws.com'});
client.sendEmail({
to: 'xxx'
, from: 'xxx'
, cc: ''
, bcc: ''
, subject: 'greetings'
, message: 'your <b>message</b> goes here'
, altText: 'plain text'
}, function (err, data, res) {
if (err) {
console.log('Email send Error: ',JSON.stringify(err, null, 2));
} else {
console.log('Email send Success: ', JSON.stringify(data,null,2));
}
});
});
我正在使用 aws-sdk 和 Node 发送 AWS SES 电子邮件,并且我能够使用 AWS CLI 成功发送电子邮件。但是,由于某种原因,在我的 Node 脚本中,我的电子邮件验证失败。
代码如下:
const aws = require('aws-sdk')
const ses = new aws.SES()
const message = {
Destination: {
ToAddresses: ['example@example.com']
},
Message: {
Body: {
Text: {
Charset: 'UTF-8',
Data: 'Test body'
}
},
Subject: {
Charset: 'UTF-8',
Data: 'Test subject'
}
},
Source: 'example@example.com'
}
ses.sendEmail(message, function (err, data) {
if (err) console.log(err);
else console.log(data);
});
错误如下:
message: 'Email address is not verified. The following identities failed the check in region US-EAST-1: example@example.com',
code: 'MessageRejected',
time: 2017-12-15T15:37:26.312Z,
requestId: 'random-id',
statusCode: 400,
retryable: false,
retryDelay: 15.030260565173382
请帮忙!谢谢!
根据 AWS troubleshooting documentation:
Email address is not verified. The following identities failed the check in region (region): (identity1), (identity2), (identity3) — You are trying to send email from an email address or domain that you have not verified with Amazon SES. This error could apply to the "From", "Source", "Sender", or "Return-Path" address.
If your account is still in the sandbox, you also must verify every recipient email address except for the recipients provided by the Amazon SES mailbox simulator. If Amazon SES is not able to show all of the failed identities, the error message ends with an ellipsis.
Note: Amazon SES has endpoints in multiple AWS regions, and email address verification status is separate for each AWS region. You must complete the verification process for each sender in the AWS region(s) you want to use.
我强烈怀疑您的应用程序配置与您用于通过 CLI 成功发送测试电子邮件的配置不 100% 匹配。
检查以下配置:
- 'Source' 地址必须是 us-east-1 区域中经过 SES 验证的发件人。检查您希望从中发送电子邮件的源地址是否是您打算从中发送电子邮件的每个区域中经过验证的发件人。
- 如果启用 SES 沙盒模式,电子邮件收件人('ToAddresses' 值)也必须是 us-east-1 区域中经过 SES 验证的发件人。有关如何删除此限制的说明,请参阅“Moving Out of the Amazon SES Sandbox”。
- 确保您测试的所有客户端都在同一区域进行测试,因为每个区域的配置需要不同。错误消息提到应用程序试图在 us-east-1 中命中 SES,因此请使用
--region
选项再次在 us-east-1 区域中明确执行 CLI 测试。如果使用 CLI 默认区域,并且该区域恰好不是 us-east-1,则初始 CLI 测试可能存在缺陷。 - 如果以上所有内容看起来都正确,请仔细检查您的节点应用程序。确保 SES 客户端已针对您希望使用的区域进行配置,并且该客户端正确地将您希望发送给 SES 请求的电子邮件写入。
进一步阅读
这是我的代码,使用 node.js 以及 express、ejs 和 npm 包 node-ses
上面有解决方法,但是容易漏掉。这是第三部分,在 key 和 secret 之后,回调到 amazon - url 需要在那里并且需要为您的地区定制,在我的例子中是 eu-west-1,其他两个选择是我们-east-1 或 us-west-2.
在 IAM - 用户中找到了密钥和秘密。一旦您设置了具有编程访问权限和 AmazonSESFullAccess 权限的用户。 Select 您的用户,然后 select "Security credentials" 选项卡。向下移动并单击“创建访问密钥”。
您只能访问您的秘密密码一次。当您获得访问权限时,突出显示秘密密码,将其复制并与您的密钥一起粘贴到安全的地方。
您的发件人电子邮件必须与在 AWS SES 页面上注册的域相关。如果您不使用 Route 53 托管,您还需要在 AWS SES 页面上注册并验证电子邮件。
这是路由器代码:
app.post('/email', function(req, res) {
var ses = require('node-ses'),
client = ses.createClient({
key: 'xxx',
secret: 'xxx',
amazon: 'https://email.eu-west-1.amazonaws.com'});
client.sendEmail({
to: 'xxx'
, from: 'xxx'
, cc: ''
, bcc: ''
, subject: 'greetings'
, message: 'your <b>message</b> goes here'
, altText: 'plain text'
}, function (err, data, res) {
if (err) {
console.log('Email send Error: ',JSON.stringify(err, null, 2));
} else {
console.log('Email send Success: ', JSON.stringify(data,null,2));
}
});
});