Sending notifications via email
In this recipe, we will cover how to send emails to customers. Transactional emails are sent in response to an action by a user, such as confirmation or alert emails. Due to spam protection and other limitations, it is better to implement this kind of email with the help of external tools.
In this recipe, we will use Mailgun (https://www.mailgun.com), which is able to send these kinds of emails, as well as communicate responses.
Getting ready
We'll need to create an account with Mailgun. Go to https://signup.mailgun.com to create one. Notice that the credit card information is optional.
Once registered, go to Domains to see there's a sandbox environment. We can use it to test Mailgun's functionality, although it will only send emails to registered test email accounts. The API credentials will be displayed there:
Figure 9.5: Domain information in Mailgun
We need to register the account so we'll receive...