Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon SES nodemailer connection failing

I'm using nodejs nodemailer to connect to Amazon SES email service. It all appears simple, but I keep getting the error:

"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details."

I've already searched online and most people say it is because you have a space at the end of your secrect key or sometimes the forward slash maybe causing the problem. The last one is no longer an issue as I kept creating SMTP credentials until there wasn't one. I've created around 10 SMTP credentials now, copied and pasted the AccessKey and SecretKey in each time and I'm still getting this error. I've also tried using http://email-smtp.us-west-2.amazonaws.com as well and still got the same error.

Here is my code:

var nodemailer = require("nodemailer");
var transport = nodemailer.createTransport("SES", 
{
    AWSAccessKeyID: 'AKIA************',
    AWSSecretKey: 'AqlwF*****************************',
    SeviceUrl: 'http://email-smtp.us-east-1.amazonaws.com'
});
nodemailer.sendMail({
    transport : transport,
    sender : '[email protected]' ,
    to : '[email protected]',
    subject : 'TEST',
    html: '<p> Hello World </p>'
}, function(error, response)
{
    if(error){ console.log(error); }   
    else{ console.log("Message sent: " + response.message);}
});

Anyone know what else I can do?

like image 371
user3508995 Avatar asked Jun 26 '14 05:06

user3508995


1 Answers

This happens when you use AWS SMTP credentials. One should create an AIM user and assign a policy like the one below to it:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["ses:SendEmail", "ses:SendRawEmail"],
      "Resource": "*"
    }
  ]
}
like image 195
Jeltok Avatar answered Sep 28 '22 07:09

Jeltok