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

sendEmail() doesn't work with special character in message #63

Closed vickyRathee closed 4 years ago

vickyRathee commented 4 years ago

This works fine

var message = 'Test message';
console.log(message);
client.sendEmail({
        to: 'email@domain.com'
        , from: 'email@domain.com'
        , subject: 'Simple test message '
        , message: message
        , altText: message
    }, function (err, data, res) {
       if(err){
            console.error(err);
        }else{
            console.log(data);
        }
    });

This throw error SignatureDoesNotMatch

var message = `badFunction() is not defined:: ReferenceError: badFunction is not defined
   at Object.<anonymous> (services\test.js:19:5)`;
console.log(message);

client.sendEmail({
        to: 'email@domain.com'
        , from: 'email@domain.com'
        , subject: 'Special char test message '
        , message: message
        , altText: message
    }, function (err, data, res) {
       if(err){
            console.error(err);
        }else{
            console.log(data);
        }
    });

Screenshot

image

nho-sh commented 4 years ago

I'm seeing the same issue as described by @vickyrathee and was able to narrow it down to a specific characters in the message and/or altText, : ( ), which are also in the sample from @vickyrathee badFunction()

davidburson commented 4 years ago

I have the same problem with 3.0.0. Got around it by replacing all parentheses with angle brackets, but that's a pretty hokey solution.

markstos commented 4 years ago

Was this working in a previous version or are you a new user?

Did you check the related specs to see if we are being spec-compliant with our current behavior?

davidburson commented 4 years ago

I'm a new user. I did not check any specs.

I needed a quick solution to replace Mailgun, which suddenly started charging us. We were already using AWS for several other services. We send very little email, so I implemented an SES solution using node-ses.

I'm very thankful this issue was raised and I stumbled on it, because I never would have thought this was the problem! A quick character substitution got us up and running. I commented just in case it's helpful to someone using node-ses or the maintainers.

A suggestion: until node-ses supports parentheses, it would be great if you mention in the Readme on npm that sending parentheses is not supported. Likewise for any other characters. Could save people a lot of headaches as well as raising confidence in node-ses (if someone is trying various methods of sending email with SES, and node-ses doesn't work because their test happens to include parentheses, they will assume node-ses just doesn't work and will move on).

At this point, I'm a happy and appreciative brand-new node-ses user! I hope my comments are helpful.

nho-sh commented 4 years ago

I've noticed that it works fine on 3.0.2 and 2.2.1. Currently using 3.0.2 without any issues

markstos commented 4 years ago

@davidburson Thanks for the feedback. Sinced @NhoNho reports that there's not an issue in 3.0.0, I'm closing this. This ticket also mentioned a signature validation issue with 3.0.0, which was a issue fixed in 3.0.2, so maybe these items were somehow related.

sandeshgb commented 3 years ago

@markstos I tried in versions 2.2.1, 3.0.2 and recently released 3.0.3 as well characters such as round brackets, quotes still doesn't work. ex: Welcome to ABC's, and Welcome user(role) still don't work in email body. I'm using @nextnm/nestjs-ses.

sandeshgb commented 3 years ago

I've noticed that it works fine on 3.0.2 and 2.2.1. Currently using 3.0.2 without any issues

Request you to try out the below content in email body and revert: Welcome to ABC's Welcome user(role)

markstos commented 3 years ago

I don't use this module any more. You are welcome welcome to submit a pull request for consideration. I'm switching to nodemailer instead.