Reputation: 187
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?
Upvotes: 7
Views: 2325
Reputation: 1
Amazon ses allows you to send emails to and from the email addresses registered on amazon aws account. You can try verifying them, may be that is the problem.
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html
This has a description on how to verify them.
EDIT: The steps for nodemailer ses transport to work properly. 1.Get the basic ses transporter ready . It can be created in the same way you did.(Which You did)
var nodemailer = require("nodemailer");
var transport = nodemailer.createTransport("SES",
{
AWSAccessKeyID: 'AKIA************',
AWSSecretKey: 'AqlwF*****************************',
SeviceUrl: 'http://email-smtp.us-east-1.amazonaws.com'
});
mail={
transport : transport,
sender : '[email protected]' ,
to : '[email protected]',
subject : 'TEST',
html: '<p> Hello World </p>'
};
To get the access keyId and awsSecretKey from your amazon aws account.(Which you did.)
Now, once you are done with the above steps,you will be able to send mails to the email addresses you have registered with your amazon ses account.(a verification link will be sent to the email account you request access for and you need to click them to verify). The link to verify email addresses through your account is the link i posted above.
which, it appears that you haven't done. So register the email addresses you want to send emails to(and also from!) and use those email addresses in your to and from addresses of the code.
If you want to send emails to email addresses you haven't registered you need to request for a premium access. It can be found in your account under production access . A reference to that page is
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html
Hope this solves your problem. And Thank you Rob for the tip.
Upvotes: -1
Reputation: 881
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": "*"
}
]
}
Upvotes: 3