Chapter 13.
Sending emails
In this section of the book we’re going to inject some interactivity into our API, and adapt our registerUserHandler so that it sends the user a welcome email after they successfully register.
In the process of doing this we’ll cover a few interesting topics. You’ll learn:
How to use the Mailtrap SMTP service to send and monitor test emails during development.
How to use the
html/templatepackage and Go’s embedded files functionality to create dynamic and easy-to-manage templates for your email content.How to create a reusable
internal/mailerpackage for sending emails from your application.How to implement a pattern for sending emails in background goroutines, and how to wait for these to complete during a graceful shutdown.