Skip to content

msroz/go-sendgrid-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📧 go-sendgrid-example

Example of sending mail via SendGrid in Golang.

🦾 Get it started

📦 Run containers

$ make setup

# Edit environment variables
$ vim ./env/local.env

# Run docker containers
$ make up

📮 Send mails

# Healthcheck of mock-sendgrid
$ make ping

# Send a single email with default value
$ docker-compose exec app go run cmd/single/single.go

# Send a single email with some options
$ docker-compose exec app go run cmd/single/single.go -to=hoge@example.com -cc=fuga@example.com -subject=hi

# Send a single email with substitusions
$ docker-compose exec app go run cmd/substitution/substitution.go -to=foo@example.com -to=bar@example.com -to=baz@example.com -cc=fuga@example.com -subject=hi

# Send a single email with Dynamic Transactional Templates
# NOTE: This command does not work with sendgrid-maildev mock server because of no support for dynamic transactional templates. Use "real" sendgrid API instead.
# See: https://docs.sendgrid.com/ui/sending-email/how-to-send-an-email-with-dynamic-transactional-templates
$ docker-compose exec app go run cmd/template/template.go -to=hoge@example.com -cc=fuga@example.com -subject=hi -templateID=[Your template ID goes here.]

📥 Mail in mock server

Use ykanazawa/sendgrid-maildev as mock SendGrid API Server.

  • Mock SendGrid API Server running at http://0.0.0.0:3030
  • MailDev webapp running at http://0.0.0.0:1080
  • MailDev SMTP Server running at 0.0.0.0:1025

🔗 References

About

📧 Example of sending mail via SendGrid in Golang.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published