Cognito sends only 50 emails per day for verifying users, what if you need to send 1000 email a day? AWS SES is your solution!!
AWS Simple Mail Service( SES ) is a cloud based email sending service that helps in sending email for verification email, password reset, OTP and transactional emails etc.
In my previous blog we have seen how to configure user pool in cognito and came across SES option in Cognito. Today we will see how to configure SES and integration it with Cognito.
Note: I have already created cognito user pool.
Step: 1 Open the SES service in AWS account and click on Get Started.

Provide the email id with which you have to send emails to customers. You should have access to it for verification and click on Next.

Step:2 Provide the Domain name of your application and click on Next.

Step: 3 If you want to send email from different mail, mention that subdomain here,

Step: 4 Review all configurations and click on Get Started,

Post configuring the SES, you will land on his page:
- Sandbox(default): After the configuration first of all we will be in Sandbox environment by default and it has certain limitations.

- Email/Domain Verification(Mandatory): An email verification link is sent to above mentioned email and domain, please verify both. Without verification, you cannot send email to your customers with this email.

Click on the link for verification,

Congratulations! message show successful verification of an email.

On SES dashboard, in Identities we can see status will be changed.

Limitations of SES Sandbox Env:
- We can only send 200 emails in 24 hours.
- can only send 1 email per second.
- To send our customers OTP email(for example), their email should be verify beforehand and that is not possible when we have 1000s of users. If their email is not verified they will not receive any verification email/otp/password reset mails.
What to do in this case ?
Click on Request production access , fill all the details with your use case and it will open a ticket with AWS Support. Within 24 hours you will get production access.

Integration with Cognito
- Go to AWS cognito, user pool and click on Messaging field. Currently our cognito is configured with Send email with Cognito, click on Edit

- Select Send email with Amazon SES and in From email address, select the email that we verified earlier in SES. It will automatically appear post refreshing it and click on Save changes

Let’s do the testing !!
We will register a user in cognito application and cognito will send a verification email via SES. We will check FROM email address field that our user will receive for otp,
- Taking shreehan.kolbey@dockstones.com email as customer name
aws cognito-idp sign-up --client-id 6fh1t8naq3clfp1db429ilhk1i --username user101 --password P@ssw0rd1 --user-attributes Name="email",Value="shreehan.kolbey@dockstones.com" Name="name",Value="user101" --region us-east-1
{
"UserConfirmed": false,
"CodeDeliveryDetails": {
"Destination": "s***@d***",
"DeliveryMedium": "EMAIL",
"AttributeName": "email"
},
"UserSub": "c458a4a8-7081-709e-b884-c5556723a89b"
Our customer has received verification code/OTP from wivob32276@bacaki.com email that we had registered in SES.

Copy the code and verify the customer.

aws cognito-idp --region us-east-1 confirm-sign-up --client-id 6fh1t8naq3clfp1db429ilhk1i --username=user101 --confirmation-code 973778
Our Customer is verified..

Stay tuned for more blogs!!!
References:
Disposable email: https://www.disposablemail.com/