> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gofast.live/llms.txt
> Use this file to discover all available pages before exploring further.

# Emails

> Choose between Postmark, SendGrid, or Resend

## Implementation

The main logic can be found in the `service-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 the `docker-compose.yml` file.

### via CLI

Possible options are `Postmark`, `SendGrid`, `Resend`, `AWS SES` and `Local (log)`

### via Docker Compose

Possible options are `postmark`, `sendgrid`, `resend`, `ses` and `local`.

### Emails Configuration

Depending on the provider, you need to set the following environment variables in the `docker-compose.yml` file:

* for `postmark`, set `POSTMARK_API_KEY`.
* for `sendgrid`, set `SENDGRID_API_KEY`.
* for `resend`, set `RESEND_API_KEY`.
* for `ses`, set `SES_ACCESS_KEY`, `SES_SECRET_KEY`, and `SES_REGION`.
* for `local`, no configuration is needed.

```yaml theme={null}
services:
  server:
    environment:
      EMAIL_PROVIDER: postmark
      EMAIL_FROM: ${EMAIL_FROM}
      POSTMARK_API_KEY: ${POSTMARK_API_KEY}
      # EMAIL_PROVIDER: sendgrid
      # SENDGRID_API_KEY: ${SENDGRID_API_KEY}
      # EMAIL_PROVIDER: resend
      # RESEND_API_KEY: ${RESEND_API_KEY}
      # EMAIL_PROVIDER: ses
      # SES_ACCESS_KEY: ${SES_ACCESS_KEY}
      # SES_SECRET_KEY: ${SES_SECRET_KEY}
      # SES_REGION: ${SES_REGION}
      # EMAIL_PROVIDER: local
```

## Getting Secrets

### Postmark

1. Go to the [Postmark](https://account.postmarkapp.com) website.
2. Create an account or log in.
3. Go to the [Servers](https://account.postmarkapp.com/servers) page.
4. Click on the server you want to use.
5. Go the `API Tokens` tab.
6. Copy the token and set it as the `POSTMARK_API_KEY` in the `docker-compose.yml` file.

### Sendgrid

1. Go to the [SendGrid](https://sendgrid.com/) website.
2. Create an account or log in.
3. Go to the [API Keys](https://app.sendgrid.com/settings/api_keys) page.
4. Click on the `Create API Key` button.
5. Copy the key and set it as the `SENDGRID_API_KEY` in the `docker-compose.yml` file.

### Resend

1. Go to the [Resend](https://resend.com/) website.
2. Create an account or log in.
3. Go to the [API Keys](https://resend.com/api-keys) page.
4. Click on the `Create API Key` button.
5. Copy the key and set it as the `RESEND_API_KEY` in the `docker-compose.yml` file.

### AWS SES

1. Go to the [AWS](https://aws.amazon.com/) website.
2. Create an account or log in.
3. Go to the [IAM](https://console.aws.amazon.com/iam/home) page.
4. Click on the `Users` tab.
5. Click on the `Add user` button.
6. Fill in the user details and click on the `Next: Permissions` button.
7. Click on the `Attach existing policies directly` button.
8. Search for `AmazonSESFullAccess` and select it.
9. Click on the `Next: Tags` button.
10. Click on the `Next: Review` button.
11. Click on the `Create user` button.
12. Copy the `Access key ID` and `Secret access key` and set them as the `SES_ACCESS_KEY` and `SES_SECRET_KEY` in the `docker-compose.yml` file.
13. Go to the [SES](https://console.aws.amazon.com/ses/home) page.
14. Click on the `Email addresses` tab.
15. Click on the `Verify a New Email Address` button.
16. Enter the email address you want to verify and click on the `Verify This Email Address` button.
17. Go to the [SES](https://console.aws.amazon.com/ses/home) page.
18. Click on the `Regions` tab.
19. Copy the region and set it as the `SES_REGION` in the `docker-compose.yml` file.
20. Cry for using AWS.

## Need help?

Visit our discord server to ask any questions, make suggestions and give feedback :).

[https://discord.gg/EdSZbQbRyJ](https://discord.gg/EdSZbQbRyJ)
