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.
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

Adding a New Provider

To add a new provider, follow these steps in the /email/provider.go file:

  1. Add the new provider to the Provider constant.
const (
	Postmark Provider = "postmark"
	Sendgrid Provider = "sendgrid"
	Resend   Provider = "resend"
    Ses      Provider = "ses"
	Local    Provider = "local"
    Mailgun  Provider = "mailgun"
)
  1. Create a new provider struct.
type mailgunProvider struct {
    url string
}
  1. Return the new provider in the NewProvider function:
case Mailgun:
    return &mailgunProvider{
        url: "https://api.mailgun.net/v3",
    }
  1. Implement the required methods:
func (p *mailgunProvider) SendEmailToProvider(to string, subject string, body string, errorChan chan<- error) {
    // Implement the logic to send an email
}
  1. Add any new secrets in the env.go file.

  2. Fill in the docker-compose.yml file with the new provider configuration.

services:
  server:
    environment:
      EMAIL_PROVIDER: mailgun
      EMAIL_FROM: ${EMAIL_FROM}
      MAILGUN_API_KEY: ${MAILGUN_API_KEY}

Getting Secrets

Postmark

  1. Go to the Postmark website.
  2. Create an account or log in.
  3. Go to the 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 website.
  2. Create an account or log in.
  3. Go to the 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 website.
  2. Create an account or log in.
  3. Go to the 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 website.
  2. Create an account or log in.
  3. Go to the IAM 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 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 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