Я пытаюсь отправить электронное письмо с моего [email protected]
электронной почты [email protected]
, но я получаю следующую ошибку:
{
"error": {
"statusCode": 400,
"name": "InvalidParameterValue",
"message": "The From ARN <[email protected]> is not a valid SES identity.",
"code": "InvalidParameterValue"
}
}
Как адрес, так и адрес электронной почты показывают verified
статус на консоли SES, и я приложил следующую Identity Policy
к [email protected]
электронной почты [email protected]
:
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "stmt1496992141256",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::xxxxxxxxxxxxxxx:root"
},
"Action": [
"ses:SendEmail",
"ses:SendRawEmail"
],
"Resource": "arn:aws:ses:us-west-2:xxxxxxxxxxxxxxx:identity/[email protected]"
}
]
}
Однако, когда я запускаю следующий код NodeJS, я получаю вышеуказанную ошибку:
Mail.send = function(email, cb) {
var ses_mail = "From: 'AWS Tutorial Series' <" + email + ">\n";
ses_mail = ses_mail + "To: " + "[email protected]" + "\n";
ses_mail = ses_mail + "Subject: AWS SES Attachment Example\n";
ses_mail = ses_mail + "MIME-Version: 1.0\n";
ses_mail = ses_mail + "Content-Type: multipart/mixed; boundary=\"NextPart\"\n\n";
ses_mail = ses_mail + "--NextPart\n";
ses_mail = ses_mail + "Content-Type: text/html; charset=us-ascii\n\n";
ses_mail = ses_mail + "This is the body of the email.\n\n";
ses_mail = ses_mail + "--NextPart\n";
ses_mail = ses_mail + "Content-Type: text/plain;\n";
ses_mail = ses_mail + "Content-Disposition: attachment; filename=\"attachment.txt\"\n\n";
ses_mail = ses_mail + "AWS Tutorial Series - Really cool file attachment!" + "\n\n";
ses_mail = ses_mail + "--NextPart--";
var params = {
RawMessage: { /* required */
Data: new Buffer(ses_mail) /* required */
},
Destinations: [
email
],
FromArn: '[email protected]',
ReturnPathArn: '[email protected]',
Source: '[email protected]',
SourceArn: '[email protected]'
};
ses.sendRawEmail(params, function(err, data) {
if (err) return cb(err);
else return cb(null, data);
});
};
Aws docs: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html
ARN в пространстве AWS означает полное имя ресурса. Это включает следующие допустимые форматы:
arn:partition:service:region:account-id:resource
arn:partition:service:region:account-id:resourcetype/resource
arn:partition:service:region:account-id:resourcetype:resource
и все остальное недействительно. Поэтому ваш
FromArn: '[email protected]',
было бы:
FromArn: 'arn:aws:ses:us-west-2:xxxxxxxxxxxxxxx:identity/[email protected]',
Identity Policy
к обоим адресам электронной почты (отправитель и получатель). Похоже, что Amazon первоначально переводит вашу учетную запись AWS в режим «sandbox
», который запрещает отправлять электронные письма на непроверенные электронные письма. Пока режимsandbox
не отменен, вы можете отправлять электронные письма только между подтвержденными электронными письмами, к которым оба прикрепилиIdentity Policy
чтобы позволить им использовать SES.