Configuration
Emails
Choose between Postmark, SendGrid, or Resend
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
, setPOSTMARK_API_KEY
. - for
sendgrid
, setSENDGRID_API_KEY
. - for
resend
, setRESEND_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:
- Add the new provider to the
Provider
constant.
const (
Postmark Provider = "postmark"
Sendgrid Provider = "sendgrid"
Resend Provider = "resend"
Local Provider = "local"
Mailgun Provider = "mailgun"
)
- Create a new provider struct.
type mailgunProvider struct {
url string
}
- Return the new provider in the
NewProvider
function:
case Mailgun:
return &mailgunProvider{
url: "https://api.mailgun.net/v3",
}
- Implement the required methods:
func (p *mailgunProvider) SendEmailToProvider(to string, subject string, body string, errorChan chan<- error) {
// Implement the logic to send an email
}
-
Add any new secrets in the
env.go
file. -
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
- 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 Tokens
tab. - Copy the token and set it as the
POSTMARK_API_KEY
in thedocker-compose.yml
file.
Sendgrid
- Go to the SendGrid website.
- Create an account or log in.
- Go to the API Keys page.
- Click on the
Create API Key
button. - Copy the key and set it as the
SENDGRID_API_KEY
in thedocker-compose.yml
file.
Resend
- Go to the Resend website.
- Create an account or log in.
- Go to the API Keys page.
- Click on the
Create API Key
button. - Copy the key and set it as the
RESEND_API_KEY
in thedocker-compose.yml
file.
Need help?
Visit our discord server to ask any questions, make suggestions and give feedback :).