Skip to content

Notes on migrating Ghost and Mailgun to a new domain

Jason Kratz
Jason Kratz
3 min read
Old post but still relevant except for the domains I am using.

I just moved this blog from to while at the same time moving to using as the domain for Mailgun. My platform for this blog is:

  1. Fastmail for my custom domain email.
  2. Mailgun for sending emails from the blog, both transaction mails and newsletters.
  3. PikaPods for hosting Ghost itself.
  4. Porkbun as my domain registrar and DNS hosting.

These instructions are obviously geared toward that tech stack but should be similar to many other setups.

Here's how I did it.

Set up the domain to use Fastmail for email hosting

This required adding various records to the domain settings in Porkbun - MX records, SPF/DKIM, etc. The values are generated automatically by Fastmail when setting up the new domain in Fastmail's admin page so it was a simple matter of copy and paste over to Porkbun and waiting for them to propagate through the DNS system (this only took a few minutes).

Set up a subdomain to use Mailgun for email sending

This is very similar to the Fastmail setup. When adding a new domain to Mailgun it generates the required values (MX, TXT, and CNAME records) and creating the DNS records is a simple matter of copy and paste over to Porkbun. Note that this is a subdomain - the default is mg. but can be whatever you want, it just needs to be a subdomain. As above it takes a few minutes for the updates to propagate. To be clear - after this step is done there will be MX records for the root domain and different MX records for the subdomain.

Set up a new administrative email address

This is an email used inside of Ghost. It is the email address that appears on anything sent to a user from Ghost (login links, signup links, newsletters, etc). This was set up inside Fastmail.

Configure the Ghost Pod to use the Mailgun SMTP server and authentication information

The Mailgun SMTP server is used to send transactional emails, not newsletters. At the moment PikaPods does not allow editing the Ghost configuration files directly but it does provide environment variables to configure Ghost for Mailgun. Before updating these values SMTP credentials need to be created in Mailgun. This is done in the Mailgun website via Sending->Domain Settings->SMTP Credentials.

  1. Create a new password by clicking Reset Password and copy into the proper environment variable in PikaPods pod settings for Ghost.
  2. Copy the login (should be postmaster@) into the proper environment variable in PikaPods.
  3. Copy the rest of the settings and make sure to use port 465 and set the secureConnection variable to true.
  4. Use the administrative email created above as the mail__from variable.

Configure Ghost with a Mailgun API key for sending newsletters

Once again go to the Mailgun website and go to Sending->Domain Settings->Sending API Keys. Generate a new key here and copy it to your Ghost settings, specifically Mailgun Settings. You'll also type in your Mailgun subdomain here (make sure to select the proper region).

Customize Ghost portal settings

You'll want to use the administrative email as the support email address for your blog. That setting is in Ghost settings under Membership->Portal Settings->Customize->Account page. Once you enter the administrative email you'll be asked to verify it.

Customize Newsletter sender and reply-to email addresses

Not sure this is strictly needed but I set both of these values in each of my newsletters to the administrative email as well. This also requires verification.

How I handle redirects from the old domain

Porkbun has a URL redirection feature that I set up as I use Porkbun DNS for both my old domain as well as this one Those settings allow me to choose the redirect type (301 - permanent) and also tack on anything in the URL that comes after the domain. This makes redirects very easy. Porkbun also provides free SSL certificates via LetsEncrypt that get renewed automatically as long as the domain is active.

If your registrar doesn't support this there are services like Freedirector (free, no signup needed) or (free tier).

Thats it!

There are quite a few steps involved in setting this up but it wasn't difficult. The combination of PikaPods-hosted Ghost with the pay-as-you-go tier of Mailgun is a pretty inexpensive way to run a small blog with newsletters.


Related Posts

Micro posts remove from main RSS feed

Just an FYI to anyone following this blog via RSS that I removed micro posts (tagged with "micro") from the main RSS feed to keep things cleaner. They are still available here for anyone interested.

Sharing in public: a follow up

It's funny how the universe works. I wrote yesterday some thoughts I'd been having about sharing in public after reading Joan Westenberg's article and then last night I read a post from a person who talked about a recent situation at their job where

Why do we blog?

Joan Westenberg: The habit of constant sharing can also have profound effects on our internal lives. When we’re always performing for an audience, always curating our experiences for public consumption, we’re losing touch with our selves. [...] This constant curation of our lives for public consumption creates a dangerous