How to setup AWS SES email provider in your Strapi app
Tags: strapi, aws, emailprovider, awsses
Published: 2021-03-11 00:00:08

When you forgot password and want to reset it, you usually get an email that contains a link to your application. Then it will redirect you to a page where you can create a new password. An operation like this requires an email provider, such as AWS Simple Email Service (SES).

In this article, we will learn how to setup AWS SES email provider in your Strapi app.

<b>Prerequisites :</b>
- A Strapi app (Learn [how to install Strapi](https://strapi.io/documentation/developer-docs/latest/getting-started/quick-start.html#_1-install-strapi-and-create-a-new-project)) 
- A package manager, such as [Yarn](https://classic.yarnpkg.com/en/docs/install/#debian-stable) or [NPM](https://nodejs.org/en/)

<b>Step 1 : Install Strapi AWS SES email provider</b>
Open your terminal, then run :
`yarn add strapi-provider-email-amazon-ses`
or
`npm i strapi-provider-email-amazon-ses --save`

Check your `package.json` if `strapi-provider-email-amazon-ses` exists. If so, you have successfully installed Strapi AWS SES email provider.

<b>Step 2 : Create plugins.js in config directory</b>
PATH : `./config/plugins.js`
```javascript
module.exports = ({ env }) => ({
 email: {
   provider: 'amazon-ses',
   providerOptions: {
     key: env('AWS_ACCESS_KEY_ID'),
     secret: env('AWS_SECRET_ACCESS_KEY'),
     amazon: `https://email.${env('AWS_REGION')}.amazonaws.com`
   },
   settings: {
     defaultFrom: env('EMAIL_DEFAULT_FROM'),
     defaultReplyTo: env('EMAIL_DEFAULT_REPLY_TO')
   }
 },
}
```

Configuration
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2na3s0rhm8puf1wa8h5g.png)

<b>Step 3 : Fill in environment variables</b>
In `./config/plugins.js` above, we assigned a lot of environment variables. Now it’s time to fill them in.
PATH : `.env` (root directory of your Strapi app)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2r26t28ggzeuchskwr5n.png)

It is not mandatory to include defaultFrom (EMAIL_DEFAULT_FROM) and defaultReplyTo (EMAIL_DEFAULT_REPLYTO) in environment variables but optional.

<b>How do I gain my AWS security credentials ?</b>
Simply sign in to the AWS management console, then open the dropdown menu. Select My Security Credentials.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cf2il3l7d5w2f7nnra2b.jpg)

After that you will see a page like this :
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7swqkw1ydn29dftpnslv.jpg)

Learn more [how to gain your AWS security credentials](https://aws.amazon.com/blogs/security/how-to-find-update-access-keys-password-mfa-aws-management-console/).

Hooray! It’s time to start your Strapi app and make sure it works. Thanks for reading, hope you have a great day today!

Connect with me :
[LinkedIn - kevinadhiguna](http://linkedin.com/in/kevinadhiguna)
[Github - kevinadhiguna](http://github.com/kevinadhiguna)

References :
- [NPM strapi-provider-email-amazon-ses](https://www.npmjs.com/package/strapi-provider-email-amazon-ses) 
- [Strapi Amazon AWS](https://strapi.io/documentation/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/amazon-aws.html)
- [AWS Security Blog](https://aws.amazon.com/blogs/security/how-to-find-update-access-keys-password-mfa-aws-management-console/)