First off, some glossary, in the summary i mentioned that we use Mailgun for Transactional Emails, what that actually means is as follows:
Transactional emails are emails you send that contain information that the user needs, this can be things like password resets, new account detail emails, order summary or emails containing login information for a newly registered account.
An example of this is when you create a new user account in Craft CMS, they will Email that user an "Activate your account and set a password"-email to the email address set on the user account, this is a transactional email.
SendGrid defines Transactional Email it as the following:
Transactional email is a type of email sent to facilitate an agreed-upon transaction between the sender and the recipient. Transactional emails typically contain information a recipient wants or needs and consequently have very high open rates.
Read more about this here, I found it useful to know the difference between transactional email and other types of email (marketing emails), you might as well.
Back to Craft CMS
First thing we need to do is sign up for a Mailgun account, I assume you know how to do this, so let's skip ahead to adding a new domain.
You need to add your domain to Mailgun's service and Verify your domain with them to be able to send email, this is so people can't signup with a random mailgun account and send vasts amount of spam emails seemingly coming from you.
Now we've setup and verified our domain, now it is time to install and configure the Mailgun plugin:
# Tell composer to require the mailgun adapter in our project composer require craftcms/mailgun # Install the plugin php craft install/plugin mailgun
Once Mailgun is installed, go to Settings → Email, and change the “Transport Type” setting to “Mailgun”. Enter your domain name and Mailgun API Key (which you can get from your domain overview page) and click Save.
Now mailgun is installed and activated, and all emails sent from your craft site will be going through Mailgun.
Host your CraftCMS websites with a secure, affordable and easy to manage VPS provider.Get $10 free credits on signup
Book 1:1 help from me on CodeMentor, get expert advice and help with CraftCMS, Flutter or Laravel.