aheckmann / node-ses

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

HPE_INVALID_CONSTANT #17

Closed calebbrewer closed 9 years ago

calebbrewer commented 9 years ago

I'm getting [Error: Parse Error] bytesParsed: 0, code: 'HPE_INVALID_CONSTANT' when I run this:

'use strict';
var ses = require('node-ses'),
    client = ses.createClient({ key: '*****', secret: '*****', amazon: 'https://email-smtp.us-east-1.amazonaws.com' });

client.sendemail({
    to: 'test@test.com',
    from: 'reminders@test.com',
    subject: 'Sending email through Node and Amazon SES Test',
    message: 'Did you get this?',
    altText: 'Did you get this?'
}, function (err, data, res) {
    console.log('res= ' + res);

    if (err) {
    console.log(err); 
    }

    console.log(data);
});

Any thoughts?

markstos commented 9 years ago

Not off hand. Try googling that error code or generating a stack trace to see which code is generating that error. Re-open if it appears to be a bug in node-ses. You can try using console.trace instead of console.log for that purpose.

https://nodejs.org/api/console.html#console_console_trace_message

markstos commented 9 years ago

You could also try routing the request through a debugging proxy like the Charles Debug Proxy to check the raw HTTP request and response sent and received from Amazon. Does the request look valid? Does it match Amazon's spec for their SES API? What does the raw response say?

Also, did you validate 'reminders@test.com' as a sender? It seems unlikely you control email at test.com. Try sending again from from a verified sender or domain.

markstos commented 9 years ago

Likewise, try sending to a valid email address instead of one one at @test.com, which likely doesn't accept mail.

joIivier commented 7 years ago

The issue is likely due to the fact that the amazon server url you used is the one for the SMTP API, not the HTTP API. (You receive SMTP responses that cant be understood by node hence the error). So you should fix your server url, replace email-smtp by just email.

I just spent a lot of hours on this issue in my project since no tool can help you at this point. I just found by testing my credentials with postman and searching for the errors postman managed to print. These were SMTP errors that gave a clue of what was going on.

markstos commented 7 years ago

@joIivier Thanks for sharing your finding of the root case!