SMTP server setup
In order to develop our email sending functionality, we’ll need access to an SMTP (Simple Mail Transfer Protocol) server that we can safely use for testing purposes.
There are a huge number of SMTP service providers (such as Postmark, Sendgrid or Amazon SES) that we could use to send our emails — or you can even install and run your own SMTP server. But in this book we’re going to use Mailtrap.
The reason for using Mailtrap is because it’s a specialist service for sending emails during development and testing. Essentially, it delivers all emails to an inbox that you can access, instead of sending them to the actual recipient.
I’ve got no affiliation with the company — I just find that the service works well and is simple to use. They also offer a ‘free forever’ plan, which should be sufficient for anyone who is coding along with this book.
Setting up Mailtrap
To set up a Mailtrap account, head to the signup page where you can register using either your email address or your Google or GitHub accounts (if you have them).
Once you’re registered and logged in, use the menu to navigate to Testing › Inboxes. You should see a page listing your available inboxes, similar to the screenshot below.
Every Mailtrap account comes with one free inbox, which by default is called Demo inbox. You can change the name if you want by clicking the pencil icon under Actions.
If you go ahead and click through to that inbox, you should see that it’s currently empty and contains no emails, similar to this:
Each inbox has its own set of SMTP credentials, which you can display by clicking the Show Credentials link (highlighted by the red box in the screenshot above). This will expand to display the inbox SMTP credentials, similar to the screenshot below.
Basically, any emails that you send using these SMTP credentials will end up in this inbox, instead of being sent to the actual recipient.
If you’re following along, make a note of the credentials displayed on your screen (or just keep the browser tab open) — you’ll need them in the next chapter.