Amazon SES (sendmail) for node
A simple and reliable Node.js mail for sending mail through Amazon SES.
debugmodule is included if debugging is needed.
This module implements the SendEmail action only. What more do you need? ;)
var ses = require'node-ses'client = sescreateClient key: 'key' secret: 'secret' ;clientsendemailto: 'firstname.lastname@example.org'from: 'somewhereOverTheR@inbow.com'cc: 'theWickedWitch@nerds.net'bcc: 'canAlsoBe@nArray.com' 'forrealz@.org'subject: 'greetings'message: 'your <b>message</b> goes here'altText: 'plain text'// ...;
npm install node-ses
The module has one primary export:
You'll probably only be using this method. It takes an options object with the following properties:
`key` - (required) your AWS SES key `secret` - (required) your AWS SES secret `algorithm` - [optional] the AWS algorithm you are using. defaults to SHA1. `amazon` - [optional] the amazon end-point uri. defaults to `https://email.us-west-2.amazonaws.com`
Not all AWS regions support SES. Check SES region support to be sure the region you are in is supported.
var ses = require'node-ses'client = sescreateClient key: 'key' secret: 'secret' ;
The client created has one method,
sendemail. This method receives an options object with the following properties:
`from` - email address from which to send (required) `subject` - string (required). Must be encoded as UTF-8 `message` - can be html (required). Must be encoded as UTF-8. `altText` - plain text version of message. Must be encoded as UTF-8. `to` - email address or array of addresses `cc` - email address or array of addresses `bcc` - email address or array of addresses `replyTo` - email address
At least one of
bcc is required.
Optional properties (overrides the values set in
`key` - AWS key `secret` - AWS secret `algorithm` - AWS algorithm to use `amazon` - AWS end point
sendmail method transports your message to the AWS SES service. If Amazon
returns an HTTP status code that's less than
200 or greater than or equal to
400, we will callback with an
err object that is a direct translation of the XML error Amazon provides.
Check for errors returned since a 400 status is not uncommon.
data returned in the callback is the HTTP body returned by Amazon as XML.
See the SES API Response docs for details.
res returned by the callback represents the HTTP response to calling the SES REST API as the request module returns it.
# Enable in the shellDEBUG="node-ses" ./server.js
// ... or temporarily set in your code before `node-ses` is required.processenvDEBUG='node-ses';
When debugging, it's useful to inspect the raw HTTP request and response send to Amazon. These can then checked against Amazon's documentation for the SendMail API method and the common errors that Amazon might return.
To turn on debugging printed to STDERR, set
DEBUG=node-ses in the environment before running your script. You can also set
process.env.DEBUG='node-ses'; in your code, before the
node-ses module is required.
See the debug module docs for more debug output possibilities.