How to increase your email quota from 200 to 50,000 messages per day within 24 hours with AWS-SES
Tags: terraform, aws, devops, project
Published: 2022-07-01 17:22:39

In this article, you will be able to learn how you could possibly help your marketing team with their email quota problem limitation.  

Your company's big-star product is about to have a huge feature improvement and your marketing team is ready to drop a big-star marketing email campaign.  According to the data that your company has been collecting, the number of current customers and possibly new ones is more significant than the number of emails your current email provider can offer at this particular moment.    

Your marketing team brings this situation to your company email provider seeking a quick solution. In response, they advise that they could increase the number of emails that you can send but it will take a few weeks and it will cost more due to the increase in email server management and new network configuration.  
 
As you can see this is a massive deal-breaker for your company quarter profits for this year. Your company is counting on you and your team.  No pressure but you have only 24 hours to save this marketing campaign 😊.  

You might be asking yourself; how could one possibly do this in 24 hours without impacting on your company budget?  

As you can appreciate, building such a large-scale email solution can be a complex and costly challenge for companies but do not worry though AWS has your back. 
 
Let’s start by gathering the required resources that you will need to provide a solution for this issue: 

1. Amazon Simple Email Service (SES) 
2. Amazon Route 53 (_For the purpose of this project to work, you would need to own a domain name_) 

**What is SES?** 
 
SES is Amazon's email regional platform that supplies an effortless, cost-effective way for companies and individuals to send and receive email using their own email addresses and domains.   

**How does SES work?**

- Client application, act as an email sender then makes a request to Amazon SES to send email to one or more receivers. 
- Only if the sender request is valid, Amazon SES accepts email otherwise its complaint. 
- Amazon SES sends the message over the Internet to the recipient's receiver. Consider tight security and the cost while sending emails. 

**Visual representation of SES workflow** 

![ses-flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mvwy1mjz3gqk7m2myirm.png)

**SES delivery work flow are:** 

- The ISP successfully delivers the message to the recipient's inbox. 
- The recipient's email address does not exist, so the ISP sends a bounce notification to Amazon SES. Amazon SES then forwards the notification to the sender. 
- The recipient receives the message but considers it to be spam and registers a complaint with the ISP. The ISP, which has a feedback loop set up with Amazon SES, sends the complaint to Amazon SES, which then forwards it to the sender. 
 
Now is my favorite time - it is building time!!! 

**First**

You will be creating an SES and automatically verifying your Route53 domain name using Terraform to solve the marketing team issue; SES will be used to send marketing emails to thousands of customers including information about our big-star product.  A fact about SES is that SES cannot only send emails but can also receive emails, and have autoresponders, in some case can support customer tickets from incoming emails request and more.  

[Repo and instructions to complete this project can be found here](https://github.com/ValAug/AWS-SES)

```
resource "aws_ses_domain_identity" "ses_domain" {
    
    domain = var.domain
}

resource "aws_ses_domain_mail_from" "main" {
    
    domain           = aws_ses_domain_identity.ses_domain.domain
    mail_from_domain = "mail.${var.domain}"
}

data "aws_route53_zone" "zone" {

    name         = var.zone_name
    private_zone = false

}

resource "aws_route53_record" "ses_verification_record" {
  
    zone_id = data.aws_route53_zone.zone.zone_id
    name    = var.domain
    type    = "TXT"
    ttl     = "600"
    records = [join("", aws_ses_domain_identity.ses_domain.*.verification_token)]
}

resource "aws_ses_domain_dkim" "ses_domain_dkim" {
    
    domain = join("", aws_ses_domain_identity.ses_domain.*.domain)
}

resource "aws_route53_record" "amazonses_dkim_record" {
  
    count   = 3
    zone_id = data.aws_route53_zone.zone.zone_id
    name    = "${element(aws_ses_domain_dkim.ses_domain_dkim.dkim_tokens, count.index)}._domainkey.${var.domain}"
    type    = "CNAME"
    ttl     = "600"
    records = ["${element(aws_ses_domain_dkim.ses_domain_dkim.dkim_tokens, count.index)}.dkim.amazonses.com"]
}
```

**Diagram**

![Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/padgp0fswso22nln4rgj.png)

**Second**

Now that SES is completely deployed and fully domain verified it is time to increase the quota from **_200 to 50,000 message limitation._**

Before proceeding to increase SES message amount let’s understand Amazon SES initiation process: 

- AWS places all new SES accounts in the Amazon SES sandbox.  
- What happens when SES is in this sandbox?  When the account is in the sandbox, AWS applies the following restrictions: 

1. You can only send mail to verified email addresses and domains 
2. You can send a maximum of 200 messages per 24-hour period.  
3. You can send a maximum of 1 message per second. 

As you can observe, all these restrictions are great points to help you prevent fraud and abuse, and to help you protect your reputation as a sender.  Amazing!!! 

Let’s move SES from the sandbox.  Unfortunately, known to day the process to take SES out of the sandbox is done manually directly from the AWS management console: 

- [Open the Amazon SES console here](https://console.aws.amazon.com/ses/.) 
- In the navigation pane, choose Account dashboard. 
- In the warning box at the top of the console that says, **"Your Amazon SES account is in the sandbox"**, on the right-hand side, choose **Request production access**. 
- In the account details modal, select either the Marketing or Transactional radio button that best describes the majority of mail you'll be sending.

1. **Marketing email**- Sent on a one-to-many basis to a targeted list of prospects or customers containing marketing and promotional content such as to make a purchase, download information, etc. 

2. **Transactional email** - Sent on a one-to-one basis unique to each recipient usually triggered by a user action such as a website purchase, a password reset request, etc. 

- In Website URL, enter the URL of your website to help us better understand the kind of content you plan on sending. 
- In Use case description, explain how you plan to use Amazon SES to send email. To help us process your request, you should answer the following questions: 

**_1.How do you plan to build or acquire your mailing list?_
_2.How do you plan to handle bounces and complaints?_
_3. How can recipients opt out of receiving email from you?_
_4. How did you choose the sending rate or sending quota that you specified in this request?_**

- In Additional contacts, tell us where you want to receive communications about your account. This can be a comma-separated list of up to 4 email addresses. 
- In Preferred contact language, choose whether you want to receive communications in English or Japanese. 
- In Acknowledgement, check the box that you agree to only send email to individuals who've explicitly requested it and confirm that you have a process in place for handling bounce and complaint notifications. 
- Choose the Submit request button - a banner will display to confirm your request was submitted and is currently under review. 

Once you submit a review of your account details, you can’t edit your details until the review is complete. The AWS Support team provides an initial response to your request within 24 hours. 

**24 Hours later**

You will be receiving a cordial email from AWS support team with a message like this one below 

> Thank you for submitting your request to increase your sending limits. Your new sending quota is 50,000 messages per day. Your maximum send rate is now 14 messages per second. We have also moved your account out of the Amazon SES sandbox. 

**What can your marketing team do now?** 

Well, now that your account is out of the sandbox, your marketing team can send emails to any recipient, regardless of whether the recipient's address or domain is verified. However, this is important to keep in mind. You are still responsible for verifying all identities that you use as **"From", "Source", "Sender", or "Return-Path"** addresses. 

I hope this article helped you to understand more about Amazon SES limitation and its powerful feature and hopefully you will be using this example in one of your future projects.  

[Credits to AWS-SES documentation](https://docs.aws.amazon.com/ses/latest/dg/Welcome.html)