aheckmann / node-ses

An Amazon SES api for nodejs with proper error handling.
http://aheckmann.github.com/node-ses
MIT License
201 stars 37 forks source link

SignatureDoesNotMatch #58

Closed SURVESHCHAUHANMARLABS closed 4 years ago

SURVESHCHAUHANMARLABS commented 4 years ago

I have set my config as below.

var ses = require('node-ses')
let client = ses.createClient({ key: '<my key>', secret: '<my secret>',amazon: 'https://email.ap-south-1.amazonaws.com' });
console.log(client)
// Give SES the details and let it construct the message for you.
client.sendEmail({
   to: 'akhil156@gmail.com'
 , from: 'My verified domain address email'
 , subject: 'greetings'
 , message: 'your <b>message</b> goes here'
 , altText: 'plain text'
}, function (err, data, res) {
 // ...
 if(err){
  console.log(err)
  console.log('err occured.')
 }
 else{
  console.log(data)
  console.log('mail sent..check your inbox..')
 }
});

I am getting the below error.

{
  Type: 'Sender',
  Code: 'SignatureDoesNotMatch',
  Message: '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.'
}

The same config is working in aws-sdk. But I am getting this error in node-ses. Can anyone help me to figure out the problem in my setting?

markstos commented 4 years ago

Which version of node-ses?

epegzz commented 4 years ago

I'm getting the same error message. Using node-ses version 2.2.1 :)

markstos commented 4 years ago

What happens you follow the documented steps for debugging?

https://github.com/aheckmann/node-ses#debugging

epegzz commented 4 years ago

Hey @markstos, I could actually pin down the issue to the aws4 lib. So instead of using node-ses I tried using the aws4 lib directly and could still reproduce the error.

And I found out that all works if I use the region us-east-1. But if I use eu-central-1 I get the error message stated by OP.

So at least my problem does not origin in node-ses.

Edit: I added code for reproduction here: https://github.com/mhart/aws4/issues/101

@SURVESHCHAUHANMARLABS What region are you using?

markstos commented 4 years ago

@epegzz Perhaps we should switch our dependency directly the aws-sdk, which is now modularized.

Check out this out: https://www.npmjs.com/package/@aws-sdk/client-ses/v/1.0.0-beta.3

Cross reference with their API docs:

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html

Or https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SESV2.html

epegzz commented 4 years ago

@markstos and this does not require to have the CLI installed locally? 🙂

epegzz commented 4 years ago

Looks like it's a pure JS implementation👌 In that case, absolutely, always better to use 1st party software 👍

epegzz commented 4 years ago

Okay, finally I could fix the issue: https://github.com/aheckmann/node-ses/pull/60 🎉

epegzz commented 4 years ago

@markstos could you merge this PR and create a new release, please? :)

markstos commented 4 years ago

The PR looks OK to me. I'll merge and release now, and go ahead close this issue. Thanks the troubleshooting and contribution!

markstos commented 4 years ago

always better to use 1st party software

Just to comment on this. It seems like it should be true, but the original AWS SES solution was part of a massive SDK, making it a huge, constantly changing dependency which was arguably worse then this simple library.

The situation is now is better, but not by a lot. AWS did break out a library just focuses on SES-- great-- but it contains no documentation of it's own, and it's even clear if the correct docs to reference are the "SES 1" or "SES 2" docs. Even the most basic usage it's documented in the NPM package they made.

So while I will always check first on the quality of a first-party library, in this case I think a lot of users are still better off with a simple and well-documented third-party library like this one.

One day if the quality of AWS SES package improves, I may switch myself!

My biggest complaint about this package is that it lacks native promise support. Hopefully that bugs someone else, too and they will contribute it.

epegzz commented 4 years ago

The PR looks OK to me. I'll merge and release now, and go ahead close this issue. Thanks the troubleshooting and contribution!

Thanks for the merge!

And yeah, fair points with the documentation. I guess they expect everyone to figure out how to use it based on the TypeScript specs? But yeah, I would not be looking forward using that lib as it is right now either, lacking any documentation.