amazon simple email service ses example in node.js

Sample node.js code for sending email using Amazon’s simple email service SES. aws-sdk is the node.js module library for aws api. The access id and asscess key has to be obtained from aws’ iam dashboard. The ToAddresses and ReplyToAddresses has to be an array of emails. The region is the region where the SQS is, for example, us-east-1.

var aws = require("aws-sdk");
var ses = new aws.SES({"accessKeyId": "yourAccessId", "secretAccessKey": "yourAccessKey", "region": "your region"});
var eparam = {
    Destination: {
      ToAddresses: ["recipent@test.com"]
    },
    Message: {
      Body: {
        Html: {
          Data: "<p>Hello, this is a test email!</p>"
        },
        Text: {
          Data: "Hello, this is a test email!"
        }
      },
      Subject: {
        Data: "SES email test"
      }
    },
    Source: "sender@test.com",
    ReplyToAddresses: ["sender@test.com"],
    ReturnPath: "sender@test.com"
};

ses.sendEmail(eparam, function (err, data) {
  if (err) console.log(err);
  else console.log(data);
});

Search within Codexpedia

Custom Search

Search the entire web

Custom Search