in

Everything You Need To Know About AWS SES.

Check out GetResponse You can Use It For Free, By Clicking On The Link:

Using AWS SES is sort of simple. during this article i will be able to attempt to cover the way to send email through SES (using sandbox) and the way to make configuration set. Some tips also to urge out of sandbox and using SES in world scenarios.

Like many other awesome goodies from amazon, Simple Email Service is one of the very popular and highly scale-able service, used by thousands of businesses and developers across the globe. Some of the notable businesses are HBO, Siemens, Careem etc. Recently got a chance to work on it and I found it very convenient and easy to setup. The combined power of other amazon services (like SNS, SQS, Lambda) with AWS SES makes it work like a charm and fit to your business needs as required. Moreover its quite cheap as well, $0.10 for every 1,000 emails. Click here to see more on pricing.
For people who still don’t know what SES shiz is, here’s how Amazon describes it:

Amazon Simple Email Service: (Amazon SES) is a cloud-based email sending service designed to help digital marketers and application developers send marketing, notification, and transactional emails. It is a reliable, cost-effective service for businesses of all sizes that use email to keep in contact with their customers.

That’s enough of introduction, now lets start . i will be able to attempt to demonstrate the following:

  1. Add email recipients and verify them. In sandbox we’ve to verify all recipients and senders.
  2. Send email to verified recipients via Lambda function using AWS nodejs sdk.
  3. Create a configuration set to publish email sending events — like bounces, complaints, deliveries, sent emails, and rejected emails — to a specific email address via AWS SNS.
  4. Tips about the way to get out of sandbox

For this you obviously need an AWS account. check in to console and goto SES homepage.

1. Add Email Recipients:

On SES console home, from Identity Management in left bar, select “Email Addresses” then click on the large blue button saying “Verify a replacement Email Address”. Enter your email address within the popup that appears.

Now click on the “Verify This Email Address” button. you’ll be prompted with a message, check your mailbox, there would be a message expecting your attention from AWS. Click on the link inside message body of that email to verify your address as a recipient.

Before you confirm your email address, check the ‘Verification Status’ in console.

 

After you confirm, the status would be changed to confirm. You might need to reload.

Now we will use this email as a sender or recipient. Try adding another email address similarly. we’ll require them further to send and receive emails.

2. Send Email Through Lambda and SES:

Goto AWS Lambda console and click on on “Create Function” button.
Now select “Author from scratch”, give your lambda function a reputation , select Node.js 10.x as Runtime and in Role section, select “Create a replacement role with basic lambda permissions”.
Click on the orange button at heart right to make your function. you’ll be redirected to the lambda function editor/designer page.

Before we start coding, we need to allow our lambda function to access AWS SES to send emails, so goto IAM console and click on ‘Roles’.

Find your AWS Lambda role from the list and click on it. I named my lambda ‘medium-send-email-via-ses’ so my role name was “medium-send-email-via-ses-role-xe66ua7m”.

In the role summary page, click on “Attach Policies” button under permissions tab.

By default lambda execution role has only access to cloudwatch logs, if we’d like to use the other services inside it or link our lambda function to other amazon resources, we first need to explicitly grant permissions to the lambda execution role.

After clicking on “Attach Policies” button, search for “AWS SES” in policies and attach “Full access” to it. See image below.

Now go back to your lambda console, paste the code below and click save. This is a simple Node.js program that uses aws sdk to send email via SES. Make sure to change <sender_email> and <recipient_email> to the email addresses that you just verified in first step.

				
					var aws = require('aws-sdk');

var ses = new aws.SES();


exports.handler = function(event, context,callback) {
    const AWS = require("aws-sdk");
    
    // print the sample event from SNS
    console.log("Event: ", event);

    const params = {
        Destination: {
            ToAddresses: ["<recipient_email@xyz.com>"] // Email address addresses that you want to send your email to
        },
        Message: {
            Body: {
                Html: {
                    // HTML Format of the email
                    Charset: "UTF-8",
                    Data: "<html><body data-rsssl=1><h2> Go follow <a href=\"https://medium.com/@usamayousuf_62526\"> @usamayousuf_62526 </a> on medium  </h2><script>class RocketElementorAnimation{constructor(){this.deviceMode=document.createElement("span"),this.deviceMode.id="elementor-device-mode",this.deviceMode.setAttribute("class","elementor-screen-only"),document.body.appendChild(this.deviceMode)}_detectAnimations(){let t=getComputedStyle(this.deviceMode,":after").content.replace(/"/g,"");this.animationSettingKeys=this._listAnimationSettingsKeys(t),document.querySelectorAll(".elementor-invisible[data-settings]").forEach(t=>{const e=t.getBoundingClientRect();if(e.bottom>=0&&e.top<=window.innerHeight)try{this._animateElement(t)}catch(t){}})}_animateElement(t){const e=JSON.parse(t.dataset.settings),i=e._animation_delay||e.animation_delay||0,n=e[this.animationSettingKeys.find(t=>e[t])];if("none"===n)return void t.classList.remove("elementor-invisible");t.classList.remove(n),this.currentAnimation&&t.classList.remove(this.currentAnimation),this.currentAnimation=n;let s=setTimeout(()=>{t.classList.remove("elementor-invisible"),t.classList.add("animated",n),this._removeAnimationSettings(t,e)},i);window.addEventListener("rocket-startLoading",function(){clearTimeout(s)})}_listAnimationSettingsKeys(t="mobile"){const e=[""];switch(t){case"mobile":e.unshift("_mobile");case"tablet":e.unshift("_tablet");case"desktop":e.unshift("_desktop")}const i=[];return["animation","_animation"].forEach(t=>{e.forEach(e=>{i.push(t+e)})}),i}_removeAnimationSettings(t,e){this._listAnimationSettingsKeys().forEach(t=>delete e[t]),t.dataset.settings=JSON.stringify(e)}static run(){const t=new RocketElementorAnimation;requestAnimationFrame(t._detectAnimations.bind(t))}}document.addEventListener("DOMContentLoaded",RocketElementorAnimation.run);</script></body></html>"
                },
                Text: {
                    Charset: "UTF-8",
                    Data: "FYI"
                }
            },
            Subject: {
                Charset: "UTF-8",
                Data: "Email via SES"
            }
        },
        Source: "<sender_email@xyz.com>",
        ConfigurationSetName: 'my-ses-config-set'	
    };


    //   Send the email
    ses.sendEmail(params, function(err, data) {
        if (err) {
            console.log(err, err.stack);
            callback(null,"error");
        }
        else {
            console.log(data); // successful response
            callback(null,"success");
        }
    });
}
				
			

Before testing our function, we’ll first jump to step 3 — Creating a configuration set that sends bounces, complaints, deliveries, sent emails, and rejected emails to a specific email address via AWS SNS. you’ll safely skip this step if you would like to figure inside sandbox environment otherwise you don’t feel the necessity of it.

3. Creating a Configuration Set:

In SES management console, click on ‘Configuration Sets’ from left sidebar. Read the outline mentioned on the page to urge a far better understanding then click on ‘Create Configuration Set’. provides it a reputation and click on create.

Click to edit it. In Event destinations tab, add a destination from the dropdown and select SNS.

Select the check boxes consistent with your need. For demo purposes I even have selected Delivery, bounce and complaint. within the topic dropdown select “Create a replacement Topic”.

Now give SNS topic an appropriate name and click on create. we’ll then create an email subscription to the present SNS topic which can eventually send all the bounces, complaints and delivery notifications via email to the subscribed address.

Goto SNS console and click on on the subject we just created then click on “Create Subscription”. Select “Email” in protocol and enter your email address. you’ve got to verify your email for SNS also a bit like we did in initiative . confirm to enter an email address aside from those you’ve got already verified for SES.

Go back to Lambda console and open the function we created previously. To test the function click on “test” button on top right corner of lambda editor. Search the keyword “SNS” in “Event Template” and select “Amazon SNS topic Notification” and click “Create” button.

After creating sample event, click on ‘Test’ button again to check your lambda function. If everything works fine, you’ll receive an email on the address you declared in your function. just in case of any error you’ll watch the logs in cloudwatch.

Thats it ! We just send an email via SES. So simple and straightforward (apart from the configuration set part). Also we got the ‘Mail Delivery’ alert, because of SES configuration set that we configured.

The Email via SES flow works like following:

Lambda -> SES -> Email

& the Configuration Set flow works like:

Lambda -> SES -> Configuration Set -> SNS -> Subscribed Email Address

But this was Sandbox and clearly if got to use it practically, we cant roll in the hay this manner (explicitly verifying every email address first, plus in sandbox we will only send 200 emails a day) and that we need to get out of sandbox environment.

4. Tips To Get Out of Sandbox Environment:

We have to request a limit increase to use AWS SES practically, like for marketing, email alerts, push notifications to subscribers etc. If you state your use case clearly, likelihood is that that you simply will get your limit increase approved within every week . But a couple of things should be taken care of before applying for it, in order that you give them no chance to reject your request:

  1. Make sure you’ve got setup your Configuration set and you’ve got an idea for your bounces, rejects and complaints etc. If not, AWS representative will reject your request and can ask you to setup configuration set first.
  2. Fill all fields, even the optional ones (like mail type, website url etc)
  3. Never ever select “NO” when asked “My email-sending complies with the AWS Service Terms and AUP” :p
  4. Always select “YES” when asked “I have a process to handle bounces and complaints”
  5. In Case description, mention your use case clearly and check out to justify the limit you’re posing for .
  6. Submit your request and avoid spamming 😀 !!!

Delete your AWS resources if you’re just practicing. That’s it for today, thanks for reading. Please give feedback about the article in comments below. be happy to ask any question or give your suggestions.

Check out Aweber You can Use It For Free, By Clicking On The Link:

Leave a Reply

Your email address will not be published. Required fields are marked *

what is smtp disposkill

SMTP Server 2022: Everything That You Need To Know

how to install mailwizz disposkill

How To Install MailWizz On Your Website