Email marketing remains one of the most effective ways to reach customers and nurture leads. Integrating Ghost CMS with Mailgun's email delivery service can provide a powerful boost to your email strategy.

The Benefits of Using Ghost and Mailgun for Email

  • Reliable delivery and tracking with Mailgun
  • Easy email newsletter creation in Ghost
  • Automated transactional emails through Mailgun SMTP
  • Affordable pricing, especially for small lists

MailGun Pay As You Go

I know for me Mailgun's pay as you go plan was a bit tricky to understand so I hope I can make it clearer here.

How To Sing Up for Flex Pay As You Go

To access the Flex pay-as-you-go pricing model, you first need to start a Foundation trial. Once the trial is started, you can then downgrade from Foundation to the Flex plan.

💡
This is because the Flex plan is not directly available as a starting plan, but can be accessed as a downgrade option from other paid plans.

Be sure to downgrade to Flex during the trial period if you want pay-as-you-go billing - otherwise the account will convert to a paid monthly Foundation plan by default at the end of the trial. Reach out to Mailgun support if you need any assistance downgrading to the Flex pay-as-you-go plan.

How Mailgun's Pay-As-You-Go Billing Works

Mailgun uses a pay-as-you-go (PAYG) billing model for its Flex plan. Here's an overview of how it works:

  • The Flex plan includes 1,000 free emails per month. No subscription fee is charged.
  • After the first 1,000 emails, additional emails are billed at $1 per 1,000 emails sent.
  • So if you send 1,001 emails, you will be charged $1. At 1,500 emails sent, the charge would be $2.
  • Charges accrue only for the current month. No balance rolls over month-to-month.
  • If you send 1,000 or fewer emails in a month, your invoice will show $0 due.
  • The $1 minimum charge is to simplify billing and processing fees.
  • The one-month Foundation trial works similarly, with 5,000 free emails and $1 minimums charged after that.
  • At the end of the trial, accounts convert to a paid subscription plan.

The PAYG approach helps you only pay for what you actually use each month. Review your monthly email volumes to determine if the Flex plan or a paid subscription makes more sense.

Key Differences Between Mailgun's Free and Flex Plans

Mailgun offers both a free plan and a flexible "Flex" plan for sending email. Understanding the differences can help you choose the right option.

The free plan has no credit card required. You get 5,000 included emails per month, with a daily limit of 300. Data retention is 1 day for logs and API events. Custom domains and extra authorized recipients are not included.

With the Flex plan, a credit card is required. The daily send limit is removed, and you get 1,000 emails free per month before pay-as-you-go charges apply. Data retention extends to 5 days. Custom domains and 5 routes are included.

Other key differences:

  • The free plan has a 5 authorized recipient maximum. The Flex plan has no recipient limit.
  • Downgrading from Flex to Free is not allowed. Flex is the minimum for existing accounts.
  • The Foundation trial works like Flex with a 5,000 email free trial period.

For higher email volumes, Mailgun's paid plans provide more features and higher send quotas. Evaluate your specific email needs to determine if a free, Flex, or paid plan makes the most sense long-term.

Configuring Ghost to Send Bulk Emails

  • Create a subdomain (e.g. m.yourdomain.com) in Mailgun
  • Add required DNS records for the subdomain

One of the key benefits of using Mailgun with Ghost is the ability to easily send bulk email newsletters to subscribers. To get this configured, there are a few simple steps:

Create Sending Subdomain

First, you'll need to create a subdomain in Mailgun that will be dedicated to sending your Ghost newsletters. The recommended approach is to use a subdomain like m.yourdomain.com.

Adding Records to Your DNS

After creating the subdomain, Mailgun will provide you with some DNS records that need to be added for the subdomain. These include an SPF record, DKIM records, and MX records. Adding these DNS records verifies ownership of the subdomain and allows Mailgun to send emails on your behalf.

I would advise here to use either CloudflareBunnyDNS or some other DNS provider to make things easy and secure.

Once you're done you hit the Verify DNS Settings button. If might take a few mins but after hitting it all the section labels will turn green. If you're having trouble

Configuring Ghost to Send Newsletters

  • Generate an API key in Mailgun for Ghost integration
  • Enter Mailgun settings in Ghost admin under Newsletters

Generate Your API Key

Next, you need to generate an API key in your Mailgun account that will be used by Ghost. Be sure you generate the key under "API Keys" rather than "Sending API Keys." The API key allows Ghost to communicate with Mailgun to trigger and track your newsletter emails.

  1. Go to the Top right corner of your dashboard,
  2. Hit the down arrouns on your account name
  3. Go to "API Security Option"
  4. Scroll down to the last section labelled "Mailgun API Keys"
  5. Hit the button "Add New Key"
  6. Give it a description
  7. Hit Create Key
  8. Make sure to copy the k

Add You API Key to Ghost

Finally, in the Ghost admin under Newsletters, you can enter your Mailgun domain and API key. This connects your Ghost site to Mailgun and enables the email sending capabilities.

  1. Login into your Ghost Admin dashboard
  2. Go into "Settings" by clicking the gear icon on the bottom left
  3. Scroll to Newsletters in the Email Newsletter section (or use the search function)
  4. Lookg for the Mailgun settings option box and hit Edit
  5. Add the location you configured (US/EU) when you were adding the domain
  6. Add the domain you configured ex m.yourdomain.com
  7. Add the key you just generated and hit save

If all goes well you will see your Mailgun setting with a green checkmark.

Once these steps are completed, you'll be ready to start creating newsletter campaigns in Ghost and sending bulk emails to your subscriber list through Mailgun. The integration provides excellent deliverability and tracking of your email marketing efforts.

Enabling Transactional Emails

  • Create an SMTP user credential in Mailgun
  • Add SMTP details to Ghost config file manually via SSH
  • Restart Ghost server for changes to take effect

In addition to newsletter emails, Ghost relies on transactional emails for things like new user invites, password reset emails, and other automated messages. Mailgun can also handle these types of transactional emails.

💡
Transaction emails are a bit more tricky to set up, you need to have SSH access to your server or installation.

Create an SMTP user credential in Mailgun

To set this up, you first need to create an SMTP user credential in your Mailgun account under "SMTP Credentials." This generates a username and password that will allow Ghost to send emails through Mailgun SMTP.

1. Go to your Mailgun Dashboard twist down on Sending

2. Click on the domain you added earlier

3. Navigate down the left side menu to Domain Settings 

4. Navigate to the "SMTP Credentials Tab" and Click the Blue Button to the Right "Add New SMTP User"

5. Add a new user, this is the email address that will send your transaction emails. You can choose if you want to add your own password or have Mailgun generate it for you automatically. Hit create user. You password will appear on a small popup to the bottom right. Hit copy and save this password.

Add SMTP details to Ghost config file manually via SSH

Next, you'll need to manually add the SMTP credentials to the Ghost configuration file. This involves editing the config file via SSH.

💡
You can connect to your server installation in two main ways: through the command line or an app like FileZilla. In this example, I will edit the file with FileZilla and then restart the service through the command line. If you're comfortable with the command line by all means use the "nano" and "touch" commands to edit the file. I find its a bit easier in this method to avoid errors.

You'll want to locate the config.production.json file and add a block with your Mailgun SMTP username and password.

1. Login to you server either by Filezilla or SSH

2. Navigate and open the config.production.json file. This will be in the root install of your Ghost installation for instance: /var/www/mydomain

3 Edit the Mail block in the Ghost config file

Open the file in your preferred editor and replace the default mail block

With the following.

"mail": {
  "transport": "SMTP",
  "options": {
    "service": "Mailgun",
    "auth": {
      "user": "[email protected]",
      "pass": "mailgunkey"
    }
  }
},

Be sure to replace the username and password with the actual credentials generated in Mailgun.

4 Restart Ghost and Test

The final step is to restart the Ghost server for the config changes to take effect. You'll want to log in via SSH, navigate to the same Ghost installation folder and run ghost restart to fully restart the Ghost process. You must be sure to use your ghost user account and not the root account.

Once restarted, Ghost will now send all transactional emails through Mailgun's SMTP service. This provides reliable delivery and tracking of automated emails.

💡
Be sure to test you newsletter sending and transactional emails

Why Ghost and Mailgun are a Powerful Combo

Using Ghost CMS with Mailgun for email delivery provides a streamlined, affordable, and scalable solution for small businesses and publishers. There are several key advantages to this integrated approach:

  • No need to pay for multiple services - With Ghost and Mailgun, you get everything you need in one bundle. A publishing platform, email newsletters, and transactional email without having to pay or manage connections across multiple vendors.
  • Provides both publishing platform and email delivery - Ghost gives you a great-looking site and content management tools while Mailgun seamlessly handles reliable email sending and tracking.
  • Easy to self-host and maintain with Ghost - You can easily install Ghost yourself on a server like DigitalOcean and manage everything yourself. Regular updates keep Ghost running smoothly for self-hosted sites.
  • Scales affordably as your list grows - Mailgun has pay-as-you-go pricing that starts free for up to 1,000 emails per month. Costs remain reasonable even as your subscriber list gets bigger.

For lean teams or small publications sending professional emails, Ghost and Mailgun make an efficient combination. You get powerful tools to manage both your content and communication with customers or readers.


Hope you found this article helpful. If you have any questions or need any troubleshooting, please let me know.