Wednesday, 10 May 2017

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. I am making a web app which allows user to log in using AWS Cognito so I dont have their email addresses in database. 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? b)If yes, how can we use the cognito identity pool to verify their email addresses for 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. The following identities failed the check in region US-WEST-2: xyz@gmail.com



via user3930213

No comments:

Post a Comment