简体   繁体   English

使用SES node.js发送电子邮件

[英]Sending email using SES node.js

I am trying to send email to my other email from amazon SES verified email, but the programs gives an error that email address in to field is not verified. 我正在尝试通过亚马逊SES验证的电子邮件向我的其他电子邮件发送电子邮件,但程序会出现错误,即未验证电子邮件地址到字段。 I am making a web app which allows user to log in using AWS Cognito so I dont have their email addresses in database. 我正在制作一个允许用户使用AWS Cognito登录的Web应用程序,因此我没有在数据库中使用他们的电子邮件地址。 I need to send email to them on an event(I cannot use SNS because I need to send emails to selective persons which I have figured out.) So my questions are: a)Do we need to verify SES email of the recipient also? 我需要在活动上向他们发送电子邮件(我不能使用SNS,因为我需要向我已经想到的选择性人员发送电子邮件。)所以我的问题是:a)我们是否还需要验证收件人的SES电子邮件? b)If yes, how can we use the cognito identity pool to verify their email addresses for SES. b)如果是,我们如何使用cognito身份池来验证他们的SES电子邮件地址。

code: 码:

var aws = require("aws-sdk");
aws.config.update({
    region: "us-west-2",
});

var ses = new aws.SES({"accessKeyId": "Mykey", "secretAccessKey":"YY","region":"us-west-2"})



var to = ['xyz@gmail.com']
var from='abc@gmail.com'




ses.sendEmail( {
    Source: from,
    Destination: { ToAddresses: to },
    Message: {
            Subject:{
    Data:"Sending emails through SES"
},
        Body: {
    Text: {
        Data: 'Stop your messing around',
    }
}
}
}
, function(err, data) {
    if(err) throw err
    console.log('Email sent:');
    console.log(data);
}

Error: 错误:

MessageRejected: Email address is not verified. MessageRejected:未验证电子邮件地址。 The following identities failed the check in region US-WEST-2: xyz@gmail.com 以下身份未通过区域US-WEST-2:xyz@gmail.com检查

If you're testing this inside your SES sandbox, you need to manually verify the recipient email addresses before it will allow you to send. 如果您在SES沙箱中对此进行测试,则需要先手动验证收件人电子邮件地址,然后才能发送。

This step isn't required after leaving the sandbox, but it's a reasonable default safety setting when testing email-related functionality during development and not wanting bogus emails to go our for real. 离开沙箱后不需要执行此步骤,但在开发期间测试与电子邮件相关的功能时,这是一个合理的默认安全设置,并且不希望伪造的电子邮件真实地发送给我们。

Amazon SES Email Sending Errors (relevant portion in bold): Amazon SES电子邮件发送错误 (相关部分以粗体显示):

Email address is not verified. 电子邮件地址未经过验证。 The following identities failed the check in region : , , —You are trying to send email from an email address or domain that you have not verified with Amazon SES. 以下身份未通过签入区域:,,,您正尝试从尚未通过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 如果您的帐户仍在沙盒中,则还必须验证每个收件人电子邮件地址

An easier way to test your email sending in AWS without needing to send actual emails would be to use their mailbox simulator : 在AWS中测试您的电子邮件发送而不需要发送实际电子邮件的更简单方法是使用他们的邮箱模拟器

The Amazon SES mailbox simulator is a set of test email addresses. Amazon SES邮箱模拟器是一组测试电子邮件地址。 Each email address represents a specific scenario. 每个电子邮件地址代表特定方案。 You can send emails to the mailbox simulator when you want to: 您可以在以下情况下向邮箱模拟器发送电子邮件:

Test your application without having to create test "To" addresses. 无需创建测试“收件人”地址即可测试您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM