Setting up Emails in Ghost CMS

Ghost CMS comes with direct integration with MailGun - an email service provider. You just need to go and get subscribed at MailGun, get your api information and set it up in CMS and it works.

Setting up Emails in Ghost CMS

Recently I was working on setting up a self-hosted Ghost CMS for my blog. I was able to do all the installation work very quickly, thanks to Ghost CMS setup documentation.

The only thing I was struggling was to setup the emails. This is very important for any website as all the communication that happens is using emails.

Ghost CMS comes with direct integration with MailGun - an email service provider. You just need to go and get subscribed at MailGun, get your api information and set it up in CMS and it works. I did the same, but to be honest MailGun is the worst provider I would say. Let me explain why. I myself I am a software engineer so I was able to create the account and setup the apis with some struggle as their interface is not user-friendly. Even after setting up everything I was not able to send emails out. I went ahead and checked the logs and turns out I had to go and verify my account using the link they sent during the account creation. I clicked on the link to verify the email, it took me to a page where you need to enter your phone number and submit. Here on this form MailGun was throwing some weird error.

An error occurred while attempting to send your verification code. 
This phone number could already be associated with another account, 
or there may be too many active verification codes. 
If the issue persists, please login to your account and contact support.

I contacted the MailGun support via an email first, and I instantly got a reply from them (I suppose was a bot). After that they didn't come back. I went ahead and opened a support ticket from their portal. The same thing happend here initial response was quick and they asked for some more information, which I provided them immediately. But then it was all quite and no more response. I kept asking for updates and response but they didn't budge. After sending them several messages I gave up and started looking for alternatives. I posted on ghost forums and saw so many people asking for the same. I considered so many options, one of the them was using iCloud mail.

Since I already had an iCloud subscription I thought to give it a try. I started doing research on how to point my personal domain to use iCloud as email server. And apple's documentation was there to help. It was an easy and straight forward setup. I am going to explain everything here.

Setup iCloud as Email Server for Personal Domain

This is first step where you need to have an iCloud+ subscription. Since I already had it I had nothing to do. except just setup your primary iCloud email Account. This is very important as this email account will be used in Ghost CMS.

Set up a custom email domain for iCloud Mail on all your devices
Learn how to set up a custom email domain for iCloud Mail and access your email addresses on all your devices.

The next step is to setup your custom domain to use iCloud Mail. Apple has separate documentation based on what device you are using to setup this. I am posting a link to documentation for MacBook, as I was using MackBook to do the setup.

Add an email domain you already own to iCloud Mail on iCloud.com
On iCloud.com, you can configure a custom email domain you already own to customize iCloud Mail.

I am not writing all the steps here as they are explained very clearly in this document. Once you are done with setting up DNS records and creating the email accounts, now its time to setup your Ghost CMS to use your iCloud Mail to send out emails.

Here is an article I found to do this. This articles explains some very important points that I would have struggled a lot but I didn't as I found this article in the first place.

How to: Configure Ghost email SMTP for iCloud custom domain
Struggling to configure Ghost to use iCloud? Here’s how to do it.

Here is apple's article explaining How to setup smtp configuration to use iCloud mail to send emails.

iCloud Mail server settings for other email client apps - Apple Support (AE)
Use these iCloud Mail server settings to manually set up your iCloud Mail account in an email client app.

Here is how your mail settings in your config.production.json file of your ghost cms should look like.

"mail": {
    "transport": "SMTP",
    "from": "[email protected]",
    "options": {
      "host": "smtp.mail.me.com",
      "port": 587,
      "auth": {
        "user": "[email protected]",
        "pass": "your-2fa-api-password"
      }
    }
  },

Summary

Important points to remember.

  1. Your email configuration should look exactly like above. Please remove anything extra if you have.
  2. In auth section the user property should point to your primary iCloud email account.
  3. In auth section the pass property should use application password and not your email password. Here is how you can generate an application password https://support.apple.com/en-us/102654
  4. from email should be any of your personal domain emails you created during the setup.

That's it. :)

You can go ahead and check if everything is working fine.

Liked it ?

Read more