Send AWS SES email with javascript

Posted by Joe Enos on August 04, 2021 · 2 mins read

 Using the node-ses package:

"use strict"; 

var ses = require('node-ses'),
client = ses.createClient({
key: 'mykey',
secret: 'mysecret' ,
amazon: "https://email.us-west-2.amazonaws.com"
});

// Give SES the details and let it construct the message for you.
client.sendEmail({
to: 'someone@example.com',
,from: 'someone@example.com',
, cc: 'someone@example.com',
, bcc: ['canbearray@example.com, 'someone@example.com']
    , subject: 'Test Message ' + new Date()
    , message: 'your <b>message</b> goes here'
    , altText: 'plain text'
    }, function (err, data, res) {
 
        if (err) {
            console.log("ERROR");
            console.log(err);
        } else {
            console.log("Done");
        }
    }
);