Implementation
The main logic can be found in theservice-go-user/domain/email/provider.go file.
The local provider is a mock implementation that doesn’t require any configuration. It logs the email content to the console.
Configuration
This choice can be made using the GoFast CLI or by modifying thedocker-compose.yml file.
via CLI
Possible options arePostmark, SendGrid, Resend, AWS SES and Local (log)
via Docker Compose
Possible options arepostmark, sendgrid, resend, ses and local.
Emails Configuration
Depending on the provider, you need to set the following environment variables in thedocker-compose.yml file:
- for
postmark, setPOSTMARK_API_KEY. - for
sendgrid, setSENDGRID_API_KEY. - for
resend, setRESEND_API_KEY. - for
ses, setSES_ACCESS_KEY,SES_SECRET_KEY, andSES_REGION. - for
local, no configuration is needed.
Getting Secrets
Postmark
- Go to the Postmark website.
- Create an account or log in.
- Go to the Servers page.
- Click on the server you want to use.
- Go the
API Tokenstab. - Copy the token and set it as the
POSTMARK_API_KEYin thedocker-compose.ymlfile.
Sendgrid
- Go to the SendGrid website.
- Create an account or log in.
- Go to the API Keys page.
- Click on the
Create API Keybutton. - Copy the key and set it as the
SENDGRID_API_KEYin thedocker-compose.ymlfile.
Resend
- Go to the Resend website.
- Create an account or log in.
- Go to the API Keys page.
- Click on the
Create API Keybutton. - Copy the key and set it as the
RESEND_API_KEYin thedocker-compose.ymlfile.
AWS SES
- Go to the AWS website.
- Create an account or log in.
- Go to the IAM page.
- Click on the
Userstab. - Click on the
Add userbutton. - Fill in the user details and click on the
Next: Permissionsbutton. - Click on the
Attach existing policies directlybutton. - Search for
AmazonSESFullAccessand select it. - Click on the
Next: Tagsbutton. - Click on the
Next: Reviewbutton. - Click on the
Create userbutton. - Copy the
Access key IDandSecret access keyand set them as theSES_ACCESS_KEYandSES_SECRET_KEYin thedocker-compose.ymlfile. - Go to the SES page.
- Click on the
Email addressestab. - Click on the
Verify a New Email Addressbutton. - Enter the email address you want to verify and click on the
Verify This Email Addressbutton. - Go to the SES page.
- Click on the
Regionstab. - Copy the region and set it as the
SES_REGIONin thedocker-compose.ymlfile. - Cry for using AWS.