Amazon Simple Email Service (SES) is a cloud-based email sending service which is made to send notifications and emails. SES is a reliable way to unload the burden of sending the emails in a conventional way.
SES is very reliable and cost effective for all size of business which uses email service to keep the contact with their customers. You pay only for what you use. So we can say that it’s a pay-per-use
Verify Email Addresses:
In the Amazon free tier you are in sandbox access. with sandbox you can only send emails to that emails which you have verified. To move out of the sandbox please Request a Sending Limit Increase.
you’ll need to verify your sending domain and email address (both to
and from
). Amazon requires this, as well as keeping you in a non-prod sandbox with so many limits, in order to protect its users, the Internet, and your own email’s trustworthiness to other mail servers. Take care of this verification before trying to send any email. If you don’t, it will just give the error. Later once this is all setup and working, you can request access for production.
Visit SES Management Dashboard -> Email Addresses -> Verify a New Email Address
Sending Email:
For this article, I am using AWS SDK for SES in Node.js. I will explain how you can use SES API.
First, install the Amazon SDK.npm install aws-sdk
var aws = require("aws-sdk");
const ses = new aws.SES({"accessKeyId": "yourAccessId", "secretAccessKey": "yourAccessKey", "region": "EnterRegion"});
let params = {
// send to list
Destination: {
ToAddresses: [
[email protected]
]
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: "<p>this is test body.</p>"
},
Text: {
Charset: "UTF-8",
Data: 'Hey, this is test.'
}
},
Subject: {
Charset: 'UTF-8',
Data: "test"
}
},
Source: '[email protected]', // must relate to verified SES account
ReplyToAddresses: [
'[email protected]',
],
};
// this sends the email
ses.sendEmail(params, (err, data) => {
if (err) console.log(err)
else console.log(data)
})
The callback function will give the err
if any error occurs and the second parameter data
to give the information which SES sends back on a successful sending of a mail.
And that’s it, It will get the job done!