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 and Local (log).

via Docker Compose

Possible options are postmark, sendgrid, resend 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 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: 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"
	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.

Need help?

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

https://discord.gg/EdSZbQbRyJ