When I first installed Ghost many a year ago the most difficult element of setting it up was getting mail working. I used Mailgun for the first time during that process, and since then API-driven mail services have become pretty standard. The way mail works in Ghost now, as I understand it, is it has direct mail services baked into the app using NodeMailer for transactional emails like new subscriptions, password changes, etc. That was not the case back in 2016, and that definitely makes things easier.
The other piece regarding email for Ghost is the setup for sending a newsletter, which purposefully does not use the NodeMailer setup. To send out a newsletter---which is increasingly the functionality Ghost aligns itself with---you integrate with Mailgun to send the one-to-many emails to avoid getting the server IP address blacklisted for spam. This is an element of the software I very much appreciate as the proprietor of a hosting company :)
Anyway, setting up email in Ghost was actually far easier for me this time around. Once I got my instances url variable set correctly (see this post for setting the url variable for a Ghost container on Reclaim Cloud) setting up email was simple. To be clear, however, if you do not have a Mailgun account you will need to set one up given that's the only service Ghost integrates with out of the box. Also, Mailgun no longer has a free tier so this will definitely have an associated cost depending on the number of emails you send.*
Below is a quick how-to for getting up and running with Mailgun to send email from a specific domain taken from this post:
- Create a Mailgun account and log in.
- Under the Domains section click
Add New Domain. (Hint: copy the password, you will need it later)
- Enter the domain from where you want to send the emails.
- Update your DNS records to verify that you are an authorized for the domain.
- Verify your domain in Mailgun (when DNS changes propagate).
Also, the post Creating a Newsletter Using Ghost goes through all the details of setting up Mailgun for Ghost in great detail, so I would check that out. The long and the short of it is once Mailgun is setup the integration with Ghost is jut a API key away.
You can also set the email addresses where Newsletter recipients can reply or seek support in the Settings-->Newsletter section of Ghost, just above where you set the API:
The last piece is setting up the SMTP variables in your Docker container to use Mailgun. I believe by adding the Mailgun variables to the container you will also be pushing transactional email through that service rather than NodeMailer, but I may be wrong on this. Below are the environmental variables I added the container on Reclaim Cloud using the Additional Options-->Variables area:
Below are the names and value (which will be unique for you) that you would need to add to your container on Reclaim Cloud.
name: mail__transport value: SMTP
name: mail__from value: <Foo firstname.lastname@example.org>
name: mail__options__service value: SMTP
name: mail__options__host value: smtp.eu.mailgun.org
name: mail__options__port value: 587
name: mail__options__auth__user value: postmaster@<YOUR_MAILGUN_DOMAIN>
name: mail__options__auth__pass value: <YOUR_MAILGUN_PASS>
Having added these variables to BavaGhost has not done any damage to the instance yet, and I can confirm that transactional emails are now being sent via Mailgun. So, if I'm right, these variables are now using Mailgun for transactional emails as well, and it probably makes sense to change them and then restart your container so the changes take effect. Also, remember to be patient given you might get a nginx error for a bit until the Ghost instance fully restarts.
Also, if I am wrong about Mailgun handling transactional emails I am all ears, and have no problem editing my post to herald the real truth behind Mailgun and Ghost! :)
*I appreciate the Ghost crews' obvious impatience with folks who are railing against the machine for having to pay for email, and their response to that criticism is spot on:
Some people seem to experience a bizarre amount of anger about email configuration for reasons which are very difficult to decypher.
Fortunately, Ghost is open source — so if our many years of tireless work to make a great product don’t meet your exacting standards for free software — you can always fork the codebase and modify it to work however you would prefer.
Yeah, it can be a slog sometimes, but I appreciate the simplicity of the software and the fact that, unlike WordPress, it does not feel the need to be everything to everyone.
Cover image: Simaron's Phentland Ghost 1979 on Flickr