Profitable Tools (Legacy)

How to configure Ghost CMS to send emails with Mailgun

27 min read
YouTube video

Enjoy Ad-Free Viewing & More!

Join Inner Circle for uninterrupted content, plus:

  • Extended cuts with in-depth explanations
  • Exclusive videos not available elsewhere
  • Vote on upcoming content
  • Access to private discussions with Dave & other like-minded entrepreneurs
Join Inner Circle or Login to view.

Introduction [00:00]

In this comprehensive guide, we’ll explore how to configure a self-hosted instance of Ghost CMS to send both transactional and bulk emails using Mailgun. Ghost is a powerful content management system that offers robust email capabilities, but setting it up correctly can be challenging. This tutorial will walk you through the entire process, from understanding the different types of emails Ghost can send to configuring DNS settings, setting up Mailgun, and testing your email functionality.

Email is a crucial component of any content management system, allowing you to engage with your audience through newsletters, password resets, and other important notifications. By the end of this guide, you’ll have a fully functional email system integrated with your Ghost installation, enabling you to communicate effectively with your readers and manage your site more efficiently.

We’ll cover everything from the basics of transactional and bulk emails to the intricacies of Mailgun’s pricing structure and DNS configuration. Whether you’re new to Ghost or looking to optimize your existing setup, this guide will provide you with the knowledge and step-by-step instructions to successfully implement email functionality in your Ghost CMS.

Different Types of Emails [00:11]

Ghost CMS can send two main types of emails: transactional and bulk. Understanding the difference between these email types is crucial for properly configuring your system and leveraging Ghost’s full potential.

Transactional Emails

Transactional emails are one-to-one communications triggered by specific actions or events on your website. These emails are essential for user account management and site functionality. Examples of transactional emails in Ghost include:

  • Password reset requests
  • Login links for members
  • Staff user invitations
  • Member newsletter signup confirmations
  • Account creation confirmations

Transactional emails are critical for maintaining user engagement and ensuring smooth site operations. Without proper configuration, users may encounter issues like being unable to reset their passwords or log in to their accounts.

Bulk Emails

Bulk emails, on the other hand, are one-to-many communications, typically used for newsletters and mass communications with your audience. The most common example of bulk email in Ghost is sending email newsletters to your subscribers.

Ghost provides a user-friendly interface for sending bulk emails directly from your content management system. This feature allows you to:

  • Send blog posts as email newsletters
  • Publish content exclusively as email newsletters
  • Combine website publication with email distribution

To use bulk email features effectively, you need to have a properly configured email service and a list of subscribers or members.

Key Differences

  • Delivery Method: Transactional emails use SMTP (Simple Mail Transfer Protocol), while bulk emails in Ghost utilize an API connection.
  • Configuration: Transactional emails require server-side configuration, whereas bulk emails are set up through the Ghost admin interface.
  • Purpose: Transactional emails are functional and triggered by user actions, while bulk emails are content-driven and initiated by the site owner.
  • Volume: Transactional emails are sent individually as needed, while bulk emails are sent to multiple recipients simultaneously.

Importance of Proper Configuration

Failing to configure either type of email correctly can lead to several issues:

  • User frustration due to inability to reset passwords or receive important notifications
  • Missed opportunities for audience engagement through newsletters
  • Potential deliverability issues if emails are not set up with proper authentication

By understanding these email types and their specific requirements, you can ensure that your Ghost CMS is fully equipped to handle all your communication needs effectively.

Mailgun Pricing [02:34]

Before diving into the configuration process, it’s essential to understand Mailgun’s pricing structure, as it’s a common concern for many users. Mailgun is a reputable email service provider known for its excellent deliverability rates, but its pricing can be confusing at first glance.

Free Tier and Pay-As-You-Go Model

Contrary to what some might initially believe, Mailgun offers a generous free tier and a flexible pay-as-you-go model:

  • Free Tier: You can send up to 1,000 emails every month absolutely free.
  • Pay-As-You-Go: After exceeding the free tier, you’re charged $1 for every additional 1,000 emails sent.

This pricing structure makes Mailgun accessible for small to medium-sized blogs and websites, especially those just starting out or with modest email needs.

Cost Breakdown for Different Scenarios

To better understand how this pricing works in practice, let’s look at some examples:

  • Small Blog (500 subscribers, 2 emails/month):
  • Total emails: 1,000
  • Cost: $0 (within free tier)
  • Growing Newsletter (2,500 subscribers, 4 emails/month):
  • Total emails: 10,000
  • Cost: $9 (1,000 free + $1 x 9 for additional 9,000 emails)
  • Established Site (5,000 subscribers, 8 emails/month):
  • Total emails: 40,000
  • Cost: $39 (1,000 free + $1 x 39 for additional 39,000 emails)

Comparison with Other Providers

While Mailgun may not be the cheapest option available, its pricing is competitive when considering the quality of service and deliverability rates:

  • Amazon SES: Generally cheaper but can be more complex to set up
  • SendGrid: Similar pricing tiers but may have higher costs for some volume levels
  • Gmail: Free for low volumes but limited in features for bulk sending

Mailgun vs. Ghost Pro

It’s worth noting that email sending is included with Ghost Pro, the managed hosting solution offered by Ghost. If you’re considering whether to self-host or use Ghost Pro, keep in mind:

  • Ghost Pro’s pricing scales with the number of members/subscribers
  • The included email service can save you the hassle of setting up and managing a separate email provider
  • For larger lists, Ghost Pro might be more cost-effective when factoring in the time and effort of self-hosting

Key Considerations for Choosing Mailgun

  • Ease of Integration: Mailgun integrates seamlessly with Ghost for both transactional and bulk emails
  • Scalability: The pay-as-you-go model allows for easy scaling as your subscriber base grows
  • Deliverability: Mailgun’s reputation for high deliverability rates can improve your email performance
  • Analytics: Mailgun provides detailed analytics that can be valuable for tracking email engagement

By understanding Mailgun’s pricing structure and how it compares to alternatives, you can make an informed decision about whether it’s the right choice for your Ghost CMS email needs.

Add a New Domain [03:56]

The first step in configuring Mailgun for your Ghost CMS is to add a new domain. This process is crucial for setting up proper email authentication and ensuring good deliverability rates. Here’s a detailed walkthrough of the domain addition process:

Accessing the Mailgun Dashboard

  1. Log into your Mailgun account
  2. Navigate to the “Sending” section
  3. Click on “Domains”
  4. Look for the “Add New Domain” button

Choosing the Right Domain Name

When adding a new domain, it’s important to follow Mailgun’s best practices:

  • Use a Subdomain: Instead of using your main domain (e.g., yourdomain.com), opt for a subdomain specifically for email sending (e.g., mail.yourdomain.com or m.yourdomain.com).
  • Benefits of Using a Subdomain:
  • Protects your main domain’s reputation
  • Allows for easier management of email-specific DNS records
  • Enables you to use different email providers for different purposes without conflicts

Step-by-Step Domain Addition

  1. Enter your chosen subdomain (e.g., m.yourdomain.com)
  2. Select the appropriate region (US or EU) based on your location and target audience
  3. Toggle on the “Advanced DKIM Settings”
  4. Choose a longer DKIM key for enhanced security
  5. Click “Add Domain” to proceed

Advanced DKIM Settings

DKIM (DomainKeys Identified Mail) is an email authentication method that helps prevent email spoofing. By enabling advanced DKIM settings:

  • You increase the security of your email authentication
  • You have more control over the DKIM key rotation
  • You can potentially improve your email deliverability rates

Region Selection Considerations

When choosing between the US and EU regions:

  • Consider data privacy regulations (e.g., GDPR for EU audiences)
  • Think about the geographical location of the majority of your subscribers
  • Factor in potential differences in email delivery speed to various regions

Common Pitfalls to Avoid

  • Using your primary domain instead of a subdomain
  • Forgetting to enable advanced DKIM settings
  • Choosing a region that doesn’t align with your audience or regulatory needs

Next Steps After Domain Addition

Once you’ve added your domain, Mailgun will provide you with a set of DNS records that you’ll need to add to your domain’s DNS settings. These records are crucial for:

  • Verifying your domain ownership
  • Setting up proper email authentication (SPF, DKIM, and DMARC)
  • Ensuring high deliverability rates for your emails

By carefully following these steps to add a new domain in Mailgun, you’re laying a solid foundation for configuring your Ghost CMS to send emails effectively and securely.

DNS Settings [04:24]

After adding your domain to Mailgun, the next critical step is configuring your DNS settings. Proper DNS configuration is essential for email authentication, which in turn affects your email deliverability and reputation. Let’s dive into the details of setting up these DNS records:

Understanding DNS Records for Email

Before we start, it’s important to understand the types of DNS records we’ll be dealing with:

  • TXT Records: Used for SPF and DKIM authentication
  • MX Records: Specify mail servers for receiving email
  • CNAME Records: Used for tracking opens and clicks

SPF (Sender Policy Framework) Record

SPF helps prevent email spoofing by specifying which servers are allowed to send email on behalf of your domain.

  1. Copy the SPF record provided by Mailgun
  2. Log into your DNS provider’s control panel
  3. Add a new TXT record
  4. Set the host/name to your subdomain (e.g., “m” for m.yourdomain.com)
  5. Paste the SPF value from Mailgun
  6. Save the record

DKIM (DomainKeys Identified Mail) Authentication

DKIM adds a digital signature to your emails, allowing receiving servers to verify that the email hasn’t been tampered with.

  1. Copy the DKIM value from Mailgun
  2. Add another TXT record in your DNS settings
  3. Use the provided prefix for the host/name field
  4. Paste the DKIM value
  5. Ensure the full domain (including subdomain) is correct
  6. Save the record

MX (Mail Exchanger) Records

MX records are crucial if you’re using a subdomain for sending emails.

  1. Copy the MX record values from Mailgun (usually two records)
  2. Add new MX records in your DNS settings
  3. Set the host/name to your subdomain
  4. Paste the mail server values from Mailgun
  5. Set the priority (usually 10 for both records)
  6. Save the records

CNAME Record for Tracking

This record allows Mailgun to track opens and clicks for your emails.

  1. Copy the CNAME record from Mailgun
  2. Add a new CNAME record in your DNS settings
  3. Set the host/name as specified by Mailgun (usually “email.m” for the subdomain)
  4. Paste the provided value
  5. If using Cloudflare, ensure the proxy is turned off for this record
  6. Save the record

Verifying DNS Settings

After adding all required records:

  1. Return to the Mailgun dashboard
  2. Click on “Verify DNS settings”
  3. Wait for Mailgun to check your DNS configuration
  4. If any records fail to verify, double-check your entries and try again
  5. It may take some time for DNS changes to propagate, so be patient

Common DNS Configuration Issues

  • Incorrect subdomain usage in record names
  • Forgetting to include the full domain in DKIM records
  • Using the wrong record type (e.g., A record instead of CNAME)
  • Not waiting long enough for DNS propagation before verifying

Best Practices for DNS Management

  • Keep a record of all changes made to your DNS settings
  • Use TTL (Time To Live) values that balance quick updates with reduced DNS server load
  • Regularly audit your DNS records to ensure they remain current and correct

By meticulously setting up these DNS records, you’re ensuring that your emails sent through Ghost CMS will have the best chance of reaching your subscribers’ inboxes. Proper DNS configuration is a fundamental step in maintaining a good sender reputation and maximizing the effectiveness of your email communications.

DKIM Authentication [04:54]

DKIM (DomainKeys Identified Mail) authentication is a crucial component of email security and deliverability. It adds a digital signature to your emails, allowing receiving servers to verify that the email hasn’t been tampered with during transit. Let’s delve deeper into the process of setting up DKIM authentication for your Ghost CMS using Mailgun:

Importance of DKIM Authentication

  • Improves email deliverability by verifying the sender’s identity
  • Helps prevent email spoofing and phishing attempts
  • Builds trust with email providers and recipients
  • Can positively impact your sender reputation

Locating DKIM Information in Mailgun

  1. Log into your Mailgun account
  2. Navigate to the domain settings for your newly added domain
  3. Look for the “Authentication” section
  4. Find the DKIM record information

Components of a DKIM Record

A typical DKIM record consists of two main parts:

  1. Host/Name: Usually a combination of a selector and your domain
  2. Value: A long string containing your public DKIM key and other parameters

Step-by-Step DKIM Setup

  1. Copy the entire DKIM record value provided by Mailgun
  2. Log into your DNS provider’s control panel
  3. Create a new TXT record
  4. For the host/name field, use the provided selector (e.g., “k1._domainkey”)
  5. In the value field, paste the entire DKIM string from Mailgun
  6. Ensure the full subdomain is included if you’re using one (e.g., k1._domainkey.m.yourdomain.com)
  7. Save the record

Verifying DKIM Setup

After adding the DKIM record:

  1. Return to the Mailgun dashboard
  2. Look for a “Verify DNS settings” or similar option
  3. Click to have Mailgun check your DKIM configuration
  4. If verification fails, double-check your DNS entry for any errors

Troubleshooting DKIM Issues

Common problems and solutions:

  • Record not found: Ensure you’ve used the correct host/name
  • Invalid DKIM signature: Check for any typos in the value field
  • Propagation delay: Wait a few hours and try verifying again

Advanced DKIM Considerations

  • Key Length: Mailgun typically uses 2048-bit keys for enhanced security
  • Key Rotation: Consider setting up a schedule to regularly update your DKIM keys
  • Multiple Selectors: You can have multiple DKIM keys for different purposes or email streams

DKIM and Other Authentication Methods

DKIM works best when used in conjunction with other email authentication methods:

  • SPF (Sender Policy Framework): Specifies which servers can send email on behalf of your domain
  • DMARC (Domain-based Message Authentication, Reporting & Conformance): Tells receiving servers how to handle authentication failures

Best Practices for DKIM Management

  • Regularly monitor your DKIM status in Mailgun
  • Keep your DKIM private keys secure and never share them
  • Update your DKIM records promptly if you change email service providers
  • Use DKIM in combination with SPF and DMARC for comprehensive email authentication

By properly setting up DKIM authentication, you’re taking a significant step towards ensuring the security and deliverability of emails sent from your Ghost CMS. This authentication method adds a layer of trust to your communications, helping to protect both you and your subscribers from potential email-based threats.

Configure some MX Records [05:21]

Configuring MX (Mail Exchanger) records is a crucial step in setting up email for your Ghost CMS, especially when using a subdomain for sending emails through Mailgun. MX records tell email servers where to deliver messages addressed to your domain. Let’s explore the process of configuring MX records in detail:

Understanding MX Records

  • Purpose: MX records specify the mail servers responsible for handling email for your domain
  • Priority: Each MX record has a priority number, with lower numbers indicating higher priority
  • Multiple Records: It’s common to have multiple MX records for redundancy

When to Configure MX Records

  • Always required when using a subdomain for email sending
  • Necessary if you want to receive emails on the same domain you’re using for sending
  • Not typically needed if you’re using your primary domain and already have MX records set up for another email service

Locating MX Record Information in Mailgun

  1. Log into your Mailgun account
  2. Navigate to your domain’s settings
  3. Look for the “MX Records” section
  4. You should see two MX records provided by Mailgun

Step-by-Step MX Record Configuration

  1. Copy the first MX record value from Mailgun
  2. Log into your DNS provider’s control panel
  3. Create a new MX record
  4. Set the host/name to your subdomain (e.g., “m” for m.yourdomain.com)
  5. Paste the mail server value from Mailgun (e.g., mxa.mailgun.org)
  6. Set the priority to 10 (as recommended by Mailgun)
  7. Save the record
  8. Repeat steps 3-7 for the second MX record, using the alternate mail server (e.g., mxb.mailgun.org)

Verifying MX Record Setup

After adding both MX records:

  1. Return to the Mailgun dashboard
  2. Look for a “Verify DNS settings” option
  3. Click to have Mailgun check your MX record configuration
  4. If verification fails, double-check your DNS entries for any errors

Common MX Record Configuration Issues

  • Incorrect subdomain usage: Ensure you’re using the correct subdomain in the host/name field
  • Wrong priority values: Make sure both records have a priority of 10
  • Missing records: Both MX records provided by Mailgun should be added
  • Conflicting records: Remove any old MX records for the same subdomain if they exist

Best Practices for MX Record Management

  • Regularly audit your MX records to ensure they remain current
  • Keep a backup of your MX record settings in case you need to revert changes
  • Consider setting up monitoring for your mail servers to detect any delivery issues quickly

MX Records and Email Deliverability

Properly configured MX records contribute to email deliverability in several ways:

  • Ensure incoming emails are routed correctly
  • Help establish the legitimacy of your domain for email purposes
  • Work in conjunction with SPF and DKIM to enhance overall email authentication

Advanced MX Record Considerations

  • TTL (Time To Live): Consider setting a lower TTL for MX records to allow for quicker changes if needed
  • Backup MX servers: In some cases, you might want to set up additional MX records with lower priorities as backups
  • Testing: Use online MX record lookup tools to verify your configuration from outside your network

By carefully configuring your MX records, you’re ensuring that your Ghost CMS can handle both incoming and outgoing emails effectively. This setup is crucial for maintaining smooth communication with your subscribers and managing various transactional emails associated with your site.

CNAME Record [06:18]

The CNAME (Canonical Name) record is an important component in the Mailgun configuration for your Ghost CMS. It’s primarily used for tracking opens and clicks in your emails. Let’s delve into the details of setting up and managing this crucial DNS record:

Understanding CNAME Records

  • Purpose: CNAME records map one domain name to another, creating an alias
  • Use in Email: For Mailgun, it’s used to set up a custom tracking domain
  • Benefits: Improves deliverability and provides a branded experience in email links

Locating CNAME Information in Mailgun

  1. Log into your Mailgun account
  2. Navigate to your domain’s settings
  3. Look for the “Tracking” or “CNAME Records” section
  4. You should see one CNAME record provided by Mailgun

Step-by-Step CNAME Record Configuration

  1. Copy the CNAME record value from Mailgun
  2. Log into your DNS provider’s control panel
  3. Create a new CNAME record
  4. Set the host/name as specified by Mailgun (usually “email.m” for the subdomain)
  5. Paste the provided value (typically ending with “mailgun.org”)
  6. If using Cloudflare, ensure the proxy is turned off for this record
  7. Save the record

Verifying CNAME Record Setup

After adding the CNAME record:

  1. Return to the Mailgun dashboard
  2. Look for a “Verify DNS settings” or similar option
  3. Click to have Mailgun check your CNAME configuration
  4. If verification fails, double-check your DNS entry for any errors

Importance of CNAME for Email Tracking

  • Enables Mailgun to track opens and clicks on your emails
  • Allows for custom branded links in your emails
  • Improves the trustworthiness of your emails by using your own domain

Common CNAME Configuration Issues

  • Incorrect subdomain usage in the host/name field
  • Using the wrong record type (e.g., A record instead of CNAME)
  • Forgetting to turn off Cloudflare’s proxy feature for this record
  • Not waiting long enough for DNS propagation before verifying

Best Practices for CNAME Management

  • Regularly check the status of your CNAME record in Mailgun
  • Keep your CNAME record up to date if you change email service providers
  • Use a descriptive name for your CNAME record to easily identify its purpose

Advanced CNAME Considerations

  • SSL Configuration: Ensure your CNAME is covered by your SSL certificate for secure tracking
  • Multiple Tracking Domains: Consider setting up separate tracking domains for different email campaigns
  • CNAME Flattening: Some DNS providers offer CNAME flattening to improve performance

By properly setting up the CNAME record, you’re enabling Mailgun to accurately track engagement with emails sent from your Ghost CMS. This tracking is invaluable for understanding your audience’s behavior and optimizing your email strategy.

Verify the DNS Settings [06:35]

After configuring all the necessary DNS records (SPF, DKIM, MX, and CNAME), the final step is to verify these settings in Mailgun. This verification process ensures that your Ghost CMS is ready to send emails securely and effectively. Let’s walk through the verification process and troubleshooting steps:

Importance of DNS Verification

  • Confirms that all required records are correctly set up
  • Ensures your domain is properly authenticated for email sending
  • Helps identify any configuration issues before you start sending emails

Accessing the Verification Tool

  1. Log into your Mailgun account
  2. Navigate to your domain’s settings page
  3. Look for a “Verify DNS settings” or similar option

The Verification Process

  1. Click on the “Verify DNS settings” button
  2. Mailgun will check each DNS record (SPF, DKIM, MX, CNAME)
  3. The system will display the status of each record (verified or failed)
  4. If all records are verified, your domain is ready for use

Handling Verification Failures

If one or more records fail to verify:

  1. Note which specific records failed
  2. Double-check the failed records in your DNS settings
  3. Common issues to look for:
  • Typos in record values
  • Incorrect record types
  • Missing or incomplete records

Troubleshooting Specific Record Types

  • SPF: Ensure the TXT record is correctly formatted and includes Mailgun’s servers
  • DKIM: Verify the selector and value are exactly as provided by Mailgun
  • MX: Check that both MX records are present with the correct priorities
  • CNAME: Confirm the subdomain and value match Mailgun’s instructions

DNS Propagation Considerations

  • DNS changes can take time to propagate (usually 24-48 hours)
  • If verification fails immediately after making changes, wait a few hours and try again
  • Use online DNS lookup tools to check if your changes are visible globally

Best Practices for Successful Verification

  • Make all DNS changes in one session to ensure consistency
  • Keep Mailgun’s instructions open while making changes to avoid errors
  • Use copy-paste for record values to prevent typos
  • Document all changes made to your DNS settings

Post-Verification Steps

Once all records are verified:

  1. Test sending a few emails to ensure everything is working correctly
  2. Monitor your email deliverability and open rates initially
  3. Set up Mailgun’s logging and analytics to track performance

Ongoing Maintenance

  • Regularly check your DNS settings to ensure they remain correct
  • Update your records promptly if Mailgun provides any new instructions
  • Periodically re-verify your settings, especially after making any DNS changes

By successfully verifying your DNS settings, you’re ensuring that your Ghost CMS is fully configured to send emails through Mailgun. This verification process is crucial for maintaining good deliverability rates and ensuring that your emails reach your subscribers’ inboxes reliably.

Configure Bulk Email [06:59]

With DNS settings verified, the next crucial step is configuring bulk email sending in Ghost CMS using Mailgun. This setup allows you to send newsletters and other mass communications to your subscribers efficiently. Let’s dive into the detailed process of configuring bulk email:

Accessing Ghost Admin Settings

  1. Log into your Ghost admin panel
  2. Click on the gear icon to access Settings
  3. Navigate to the “Newsletter” section

Locating Mailgun Configuration

In the Newsletter settings, you’ll find a section specifically for Mailgun configuration. This is where you’ll enter the necessary details to connect Ghost with your Mailgun account.

Required Mailgun Information

To configure bulk email, you’ll need:

  1. Mailgun API Key
  2. Mailgun Domain
  3. Region (US or EU)

Step-by-Step Configuration Process

  1. Choose your region (US or EU) based on your Mailgun account setup
  2. Enter your Mailgun domain (e.g., m.yourdomain.com)
  3. Locate your private API key in Mailgun:
  • Log into Mailgun
  • Go to your account settings
  • Find the “API Keys” section
  • Copy the “Private API Key”
  1. Paste the API key into the corresponding field in Ghost
  2. Save the settings

Common Configuration Mistakes

  • Using the public API key instead of the private one
  • Entering the wrong domain (main domain instead of subdomain)
  • Selecting the incorrect region

Verifying Bulk Email Configuration

After saving the settings:

  1. Ghost should indicate if the connection is successful
  2. If you encounter any errors, double-check your entries
  3. Ensure your Mailgun account is active and in good standing

Testing Bulk Email Functionality

Once configured:

  1. Create a new post in Ghost
  2. Click on the email icon in the post editor
  3. Select “Send a test email” to verify the setup

Optimizing Bulk Email Settings

  • Configure email templates in Ghost to match your brand
  • Set up email groups or segments for targeted communications
  • Utilize Ghost’s scheduling feature for timely newsletter delivery

Mailgun Settings for Improved Deliverability

In your Mailgun account:

  1. Enable click and open tracking
  2. Set up domain authentication if not already done
  3. Configure unsubscribe handling

Best Practices for Bulk Emailing

  • Regularly clean your email list to remove inactive subscribers
  • Monitor your email engagement metrics in Ghost and Mailgun
  • Gradually increase your sending volume to build a good reputation
  • Use double opt-in for new subscribers to ensure list quality

Troubleshooting Bulk Email Issues

If you encounter problems:

  1. Check Ghost’s error logs for specific issues
  2. Verify your Mailgun account status and limits
  3. Ensure your DNS settings are still correct and verified

Scaling Your Bulk Email Capabilities

As your subscriber base grows:

  • Monitor your Mailgun usage and upgrade your plan if needed
  • Consider implementing email automation features in Ghost
  • Regularly review and optimize your email content and sending strategies

By carefully configuring bulk email in Ghost CMS using Mailgun, you’re setting up a powerful system for communicating with your audience. This setup allows you to leverage Ghost’s content management capabilities alongside Mailgun’s robust email delivery infrastructure, ensuring your newsletters and updates reach your subscribers effectively.

Transactional Email [09:11]

After setting up bulk email, the next crucial step is configuring transactional email for your Ghost CMS. Transactional emails are individual messages triggered by specific actions on your site, such as password resets or account notifications. Let’s dive into the process of setting up transactional email using Mailgun:

Understanding Transactional Emails in Ghost

Transactional emails include:

  • Password reset requests
  • Login links for members
  • Account creation confirmations
  • Comment notifications (if enabled)
  • Subscription confirmations

Importance of Transactional Emails

  • Essential for user account management
  • Improve user experience and security
  • Often have higher open rates than bulk emails

Accessing Server Configuration

Unlike bulk emails, transactional emails are configured at the server level:

  1. You’ll need SSH access to your Ghost server
  2. Familiarity with command-line interface is helpful

Locating the Ghost Configuration File

  1. SSH into your server
  2. Navigate to the Ghost installation directory (typically /var/www/ghost)
  3. Locate the config.production.json file

Preparing Mailgun SMTP Credentials

Before editing the configuration file, gather the following from Mailgun:

  1. SMTP hostname (usually smtp.mailgun.org)
  2. SMTP port (typically 587 for TLS)
  3. SMTP username (often your Mailgun domain)
  4. SMTP password (found in Mailgun’s SMTP credentials section)

Editing the Ghost Configuration File

  1. Open config.production.json using a text editor (e.g., nano or vim)
  2. Look for the “mail” section (if it doesn’t exist, you’ll need to add it)
  3. Update or add the following JSON structure:
"mail": {
    "transport": "SMTP",
    "options": {
        "host": "smtp.mailgun.org",
        "port": 587,
        "auth": {
            "user": "postmaster@your-domain.com",
            "pass": "your-smtp-password"
        }
    }
}
  1. Replace the placeholder values with your Mailgun SMTP credentials
  2. Save the file and exit the editor

Restarting Ghost to Apply Changes

After editing the configuration:

  1. Run the command: ghost restart
  2. Wait for Ghost to fully restart

Verifying Transactional Email Setup

To test your configuration:

  1. Try resetting your password through the Ghost admin panel
  2. Check if you receive the password reset email
  3. Verify other transactional emails by performing relevant actions (e.g., creating a new account)

Troubleshooting Transactional Emails

If emails aren’t sending:

  1. Check Ghost’s error logs for specific SMTP errors
  2. Verify your Mailgun SMTP credentials are correct
  3. Ensure your server’s firewall allows outgoing connections on port 587

Best Practices for Transactional Emails

  • Regularly update your SMTP password for security
  • Monitor delivery rates and bounce notifications in Mailgun
  • Customize transactional email templates in Ghost to match your brand

Optimizing Transactional Email Performance

  • Consider using dedicated IPs for transactional emails (available on higher Mailgun plans)
  • Implement proper authentication (SPF, DKIM) specifically for transactional emails
  • Set up email alerts in Mailgun for any delivery issues

By properly configuring transactional emails, you ensure that critical communications reach your users promptly and reliably. This setup is essential for maintaining a smooth user experience and ensuring the security of your Ghost CMS installation.

Add New SMTP User [09:38]

Before configuring transactional emails in Ghost, you need to set up a new SMTP user in Mailgun. This user will be dedicated to sending transactional emails, providing better security and easier management. Let’s walk through the process of adding a new SMTP user in Mailgun:

Accessing Mailgun SMTP Credentials

  1. Log into your Mailgun account
  2. Navigate to the “Sending” section
  3. Click on “Domains” and select your domain
  4. Scroll down to find the “SMTP credentials” section

Creating a New SMTP User

  1. In the SMTP credentials section, click on “Add New SMTP User”
  2. Choose a descriptive username (e.g., “ghost-transactional”)
  3. Mailgun will generate a strong password automatically
  4. Make sure to copy and securely store this password, as it won’t be shown again

Best Practices for SMTP User Management

  • Use a unique SMTP user for each application or service
  • Avoid using generic names like “admin” or “user”
  • Regularly rotate SMTP passwords for enhanced security

Understanding SMTP User Permissions

  • By default, new SMTP users have send-only permissions
  • This is typically sufficient for transactional emails in Ghost
  • Additional permissions can be added if needed, but exercise caution

Verifying the New SMTP User

After creation:

  1. The new user should appear in the SMTP credentials list
  2. You can test the credentials using an SMTP testing tool

Securing Your SMTP Credentials

  • Never share SMTP credentials publicly
  • Use environment variables or secure vaults to store credentials in your Ghost configuration
  • Implement IP restrictions if possible to limit where emails can be sent from

Monitoring SMTP User Activity

  • Regularly check Mailgun logs for any unusual activity
  • Set up alerts for failed authentication attempts

Troubleshooting SMTP User Issues

If you encounter problems:

  1. Verify the username and password are correct
  2. Check if there are any account-wide sending restrictions
  3. Ensure the SMTP user has the necessary permissions
  4. Check if your IP is whitelisted if you’ve set up IP restrictions
  5. Verify that your Mailgun account is in good standing (not suspended or limited)

Integrating New SMTP User with Ghost

Once you’ve created the new SMTP user:

  1. Update your Ghost configuration file (config.production.json) with the new credentials
  2. Use the full email address (e.g., ghost-transactional@yourdomain.com) as the username
  3. Input the generated password carefully, ensuring no typing errors

Best Practices for SMTP Integration

  • Consider using environment variables to store sensitive information
  • Implement proper error handling in your Ghost setup to catch and log SMTP issues
  • Regularly test your transactional email flow to ensure continued functionality

Add the Login Credentials [09:55]

With your new SMTP user created in Mailgun, the next step is to add these login credentials to your Ghost configuration. This process involves editing the Ghost configuration file to include the SMTP details. Let’s go through this process step-by-step:

Accessing Your Ghost Server

  1. Connect to your server via SSH
  2. Navigate to your Ghost installation directory (typically /var/www/ghost)

Locating the Configuration File

  1. The main configuration file is usually named config.production.json
  2. Use a command-line text editor like nano or vim to open the file:
   nano config.production.json

Editing the Configuration File

  1. Look for the "mail" section in the configuration file
  2. If it doesn’t exist, you’ll need to add it
  3. Update or add the following JSON structure:
"mail": {
  "transport": "SMTP",
  "options": {
    "host": "smtp.mailgun.org",
    "port": 587,
    "auth": {
      "user": "ghost-transactional@yourdomain.com",
      "pass": "your-smtp-password"
    }
  }
}
  1. Replace ghost-transactional@yourdomain.com with your new SMTP username
  2. Replace your-smtp-password with the password generated by Mailgun

Securing Sensitive Information

  • Consider using environment variables for sensitive data:
  "auth": {
    "user": "process.env.MAILGUN_SMTP_USER",
    "pass": "process.env.MAILGUN_SMTP_PASS"
  }
  • If using environment variables, ensure they’re properly set on your server

Saving and Exiting

  1. In nano, press Ctrl + X to exit
  2. Press Y to confirm saving changes
  3. Press Enter to confirm the file name

Verifying Configuration Syntax

  1. Use a JSON linter to check for any syntax errors:
   cat config.production.json | json_pp
  1. If there are any errors, the linter will point them out

Restarting Ghost

After making changes to the configuration:

  1. Restart Ghost to apply the new settings:
   ghost restart
  1. Wait for Ghost to fully restart and check for any error messages

Testing the Configuration

  1. Try to trigger a transactional email (e.g., password reset)
  2. Check your email to see if you receive the message
  3. If the email doesn’t arrive, check Ghost’s error logs for any SMTP-related issues

Troubleshooting Common Issues

  • “Authentication failed”: Double-check your SMTP credentials
  • “Connection timed out”: Ensure your server’s firewall allows outgoing connections on port 587
  • “SSL/TLS required”: Verify that you’re using the correct port (587 for TLS)

Best Practices for Credential Management

  • Regularly update your SMTP password in both Mailgun and your Ghost configuration
  • Use strong, unique passwords for each SMTP user
  • Implement proper access controls to your Ghost server and configuration files

Monitoring Email Sending

  • Regularly check Mailgun logs for any delivery issues
  • Set up Mailgun alerts for failed deliveries or authentication attempts
  • Periodically test your transactional email flow to ensure it’s working correctly

By carefully adding and managing your Mailgun SMTP credentials in your Ghost configuration, you ensure that your transactional emails are sent securely and reliably. This setup is crucial for maintaining communication with your users and providing a smooth experience on your Ghost-powered website.

Connect to My Server [10:52]

Connecting to your server is a crucial step in configuring Ghost CMS to send emails with Mailgun. This process typically involves using SSH (Secure Shell) to access your server remotely. Let’s go through the detailed steps of connecting to your server:

Prerequisites

Before connecting to your server, ensure you have:

  1. The IP address or hostname of your server
  2. SSH access credentials (username and password or SSH key)
  3. An SSH client (built-in terminal on Mac/Linux, or PuTTY on Windows)

Step-by-Step Connection Process

  1. Open your terminal or SSH client
  2. Type the following command, replacing username and server_ip with your actual credentials:
   ssh username@server_ip
  1. If it’s your first time connecting, you may see a fingerprint authentication prompt. Type ‘yes’ to continue
  2. Enter your password when prompted (note: characters won’t be visible as you type)

Using SSH Keys for Enhanced Security

If you’re using an SSH key:

  1. Ensure your private key is in the correct location (usually ~/.ssh/id_rsa on Mac/Linux)
  2. Use the -i flag to specify your key file:
   ssh -i /path/to/your/key username@server_ip

Troubleshooting Connection Issues

If you encounter problems:

  • “Connection refused”: Check if SSH is running on the server and if the port is open
  • “Permission denied”: Verify your username and password/key are correct
  • “Host key verification failed”: The server’s fingerprint has changed. Investigate before proceeding

Best Practices for Server Access

  • Use SSH keys instead of passwords for better security
  • Implement two-factor authentication if possible
  • Regularly update your server’s SSH configuration to patch security vulnerabilities
  • Consider using a bastion host or VPN for additional security layers

Navigating to Ghost Installation Directory

Once connected:

  1. Navigate to your Ghost installation directory:
   cd /var/www/ghost
  1. Verify you’re in the correct directory:
   ls -l

You should see Ghost-related files and directories

Checking Ghost Status

Before making any changes:

  1. Check the status of your Ghost installation:
   ghost status
  1. Ensure Ghost is running without any errors

Preparing for Configuration Changes

  1. Create a backup of your current Ghost configuration:
   cp config.production.json config.production.backup.json
  1. Open the configuration file for editing:
   nano config.production.json

Security Considerations

  • Always use secure, encrypted connections (SSH) when accessing your server
  • Limit SSH access to specific IP addresses if possible
  • Regularly audit your server access logs for any suspicious activity
  • Keep your server’s operating system and SSH daemon up to date

By following these steps and best practices, you can securely connect to your server and prepare to make the necessary configuration changes for integrating Mailgun with your Ghost CMS. This secure connection is essential for maintaining the integrity and security of your Ghost installation while configuring email functionality.

Edit this config production JSON [11:54]

Editing the config.production.json file is a critical step in configuring Ghost CMS to send emails via Mailgun. This file contains all the necessary settings for your Ghost installation, including email configuration. Let’s go through the process of editing this file in detail:

Locating the Configuration File

  1. Ensure you’re in the Ghost installation directory (typically /var/www/ghost)
  2. The file you need to edit is named config.production.json

Creating a Backup

Before making any changes:

  1. Create a backup of the current configuration:
   cp config.production.json config.production.backup.json
  1. This allows you to revert changes if needed

Opening the File for Editing

  1. Use a command-line text editor like nano:
   nano config.production.json
  1. If you prefer vim or another editor, use that instead

Understanding the JSON Structure

The config.production.json file is structured in JSON format. Be careful to maintain proper syntax:

  • Ensure all opening brackets { have corresponding closing brackets }
  • Use double quotes " for all keys and string values
  • Separate key-value pairs with commas

Adding or Updating the Mail Configuration

Locate the "mail" section in the file. If it doesn’t exist, you’ll need to add it. Here’s the structure you should use:

"mail": {
  "transport": "SMTP",
  "options": {
    "host": "smtp.mailgun.org",
    "port": 587,
    "auth": {
      "user": "postmaster@yourdomain.com",
      "pass": "your-mailgun-smtp-password"
    }
  }
}

Replace yourdomain.com and your-mailgun-smtp-password with your actual Mailgun credentials.

Using Environment Variables (Optional but Recommended)

For enhanced security, consider using environment variables:

"mail": {
  "transport": "SMTP",
  "options": {
    "host": "smtp.mailgun.org",
    "port": 587,
    "auth": {
      "user": "process.env.MAILGUN_SMTP_USER",
      "pass": "process.env.MAILGUN_SMTP_PASS"
    }
  }
}

If using this method, ensure you’ve set these environment variables on your server.

Verifying JSON Syntax

  1. After making changes, use a JSON linter to check for syntax errors:
   cat config.production.json | json_pp
  1. If there are any errors, the linter will highlight them

Saving Changes

In nano:

  1. Press Ctrl + X to exit
  2. Press Y to confirm saving changes
  3. Press Enter to confirm the file name

Common Pitfalls to Avoid

  • Missing commas between JSON objects
  • Unmatched brackets or quotation marks
  • Using single quotes instead of double quotes
  • Forgetting to replace placeholder values with actual credentials

Testing Your Configuration

After saving:

  1. Restart Ghost: ghost restart
  2. Check Ghost logs for any startup errors: ghost log
  3. Try sending a test email (e.g., password reset) to verify the configuration

Troubleshooting

If you encounter issues:

  1. Double-check your Mailgun credentials
  2. Verify that all JSON syntax is correct
  3. Ensure the mail section is at the correct level in the JSON structure
  4. Check Ghost logs for specific error messages

Best Practices

  • Always backup before editing configuration files
  • Use environment variables for sensitive information
  • Regularly update your SMTP credentials for security
  • Keep your Ghost installation and configuration up to date

By carefully editing the config.production.json file, you’re setting up Ghost to securely and efficiently send emails through Mailgun. This configuration is crucial for both transactional and bulk emails, ensuring smooth communication with your site’s users and subscribers.

Restart Ghost [12:41]

After making changes to the config.production.json file, it’s crucial to restart Ghost to apply the new configuration. Restarting Ghost ensures that all changes take effect and allows you to verify if the new settings are working correctly. Let’s go through the process of restarting Ghost in detail:

Importance of Restarting Ghost

  • Applies new configuration changes
  • Clears any cached settings
  • Allows Ghost to reinitialize with the updated email settings

Preparing for Restart

Before restarting:

  1. Ensure all configuration changes are saved
  2. Check that you’re still in the Ghost installation directory (/var/www/ghost)
  3. Verify you have the necessary permissions to restart Ghost

Command to Restart Ghost

The basic command to restart Ghost is:

ghost restart

Step-by-Step Restart Process

  1. Open your terminal (ensure you’re still connected via SSH)
  2. Navigate to the Ghost directory if you’re not already there:
   cd /var/www/ghost
  1. Run the restart command:
   ghost restart
  1. Wait for the process to complete

Understanding the Restart Output

During the restart, you might see output like:

✓ Validating config
✓ Checking current state
✓ Stopping Ghost
✓ Starting Ghost
Ghost is running in production mode

Verifying Successful Restart

After the restart command completes:

  1. Check the Ghost status:
   ghost status
  1. You should see output indicating Ghost is running

Troubleshooting Restart Issues

If the restart fails:

  1. Check the Ghost logs:
   ghost log
  1. Look for any error messages related to configuration or email settings
  2. Verify that the config.production.json file has correct syntax
  3. Ensure all required Ghost processes have necessary permissions

Common Restart Problems

  • Configuration syntax errors
  • Permission issues
  • Port conflicts
  • Memory or resource constraints

Best Practices for Ghost Restarts

  • Schedule restarts during low-traffic periods
  • Always check logs after a restart
  • Test critical functionality (like email sending) after each restart
  • Keep track of restart frequency and any recurring issues

Monitoring Post-Restart

After restarting:

  1. Visit your Ghost admin panel to ensure it’s accessible
  2. Try triggering a transactional email (e.g., password reset) to test the new configuration
  3. Monitor server resources to ensure Ghost is running smoothly

Automating Restarts (Optional)

For more advanced setups:

  • Consider using process managers like PM2 for automatic restarts
  • Set up monitoring tools to alert you of any Ghost downtime

Security Considerations

  • Only restart Ghost from secure, authenticated sessions
  • Regularly update Ghost to the latest version before restarting
  • Review server logs for any unusual activity around restart times

By properly restarting Ghost after configuration changes, you ensure that your email settings with Mailgun are correctly applied. This step is crucial for maintaining the functionality and stability of your Ghost CMS installation, particularly when it comes to email communications with your users and subscribers.

Test Email [13:31]

After configuring Mailgun and restarting Ghost, it’s essential to test the email functionality to ensure everything is working correctly. Testing helps verify that both transactional and bulk emails are being sent and received as expected. Let’s go through a comprehensive process of testing email functionality in Ghost:

Testing Transactional Emails

  1. Password Reset Test:
    • Go to your Ghost login page
    • Click on “Forgot password”
    • Enter your admin email address
    • Check if you receive the password reset email
  2. Staff Invitation Test:
    • In Ghost Admin, go to “Staff”
    • Invite a new user (you can use a different email address you own)
    • Check if the invitation email is received

Testing Bulk Emails

  1. Newsletter Test:
    • Create a new post in Ghost
    • Click on the email icon in the post editor
    • Select “Send a test email”
    • Enter your email address and send the test
  2. Subscriber Welcome Email:
    • Sign up as a new subscriber on your Ghost site
    • Check if you receive a welcome email (if configured)

Verifying Email Receipt

For each test:

  1. Check your inbox for the test emails
  2. If not in the inbox, check spam/junk folders
  3. Verify the email content and formatting

Checking Mailgun Logs

  1. Log into your Mailgun account
  2. Navigate to the “Logs” section
  3. Look for entries corresponding to your test emails
  4. Check for any errors or delivery issues

Analyzing Email Headers

For received emails:

  1. View the full email headers
  2. Look for “Authentication-Results” to verify DKIM and SPF passed
  3. Check the “Received” headers to trace the email’s path

Testing from Different Email Clients

If possible, test receiving emails on:

  1. Web-based email (e.g., Gmail, Outlook.com)
  2. Desktop email clients (e.g., Thunderbird, Apple Mail)
  3. Mobile email apps

Checking Email Rendering

For newsletter emails:

  1. Verify that images load correctly
  2. Check that links are working and correctly tracked
  3. Ensure the email displays properly on both desktop and mobile

Troubleshooting Common Issues

If emails are not received:

  1. Check Ghost logs for any sending errors
  2. Verify Mailgun API credentials in your Ghost configuration
  3. Check if your Mailgun account is active and within sending limits
  4. Ensure your domain’s DNS records are correctly set up in Mailgun
  5. Test sending a manual email through Mailgun’s dashboard to isolate Ghost-specific issues

Verifying Email Deliverability

  1. Use email deliverability testing tools (e.g., mail-tester.com)
  2. Send test emails to different email providers (Gmail, Outlook, Yahoo, etc.)
  3. Check your domain and IP reputation using online tools

Optimizing Email Performance

After successful testing:

  1. Monitor open rates and click-through rates in Ghost’s email dashboard
  2. Analyze Mailgun’s analytics for delivery rates and engagement metrics
  3. Adjust email sending frequency based on performance data

Best Practices for Ongoing Email Testing

  1. Set up regular automated tests for critical email functions
  2. Periodically send test newsletters to a small group of trusted subscribers
  3. Stay informed about changes in email standards and update your configuration accordingly

Documenting Test Results

  1. Keep a log of all email tests performed
  2. Document any issues encountered and their resolutions
  3. Use this information for troubleshooting future problems and for system maintenance

Setting Up Email Monitoring

  1. Configure alerts in Mailgun for delivery failures or unusual activity
  2. Set up monitoring for your Ghost instance to detect any email-related errors
  3. Regularly review Ghost and server logs for any email-related warnings or errors

Testing Email Security

  1. Verify that sensitive information is not being leaked in email headers
  2. Ensure that all links in emails are using HTTPS
  3. Test the unsubscribe functionality for newsletter emails

Gathering User Feedback

  1. Encourage subscribers to report any issues with receiving emails
  2. Set up a system to collect and analyze user feedback on email content and delivery

Compliance Testing

  1. Ensure all bulk emails include a valid unsubscribe link
  2. Verify that your emails comply with relevant regulations (e.g., GDPR, CAN-SPAM)

Performance Testing

  1. Test sending emails to a large number of recipients (within your plan limits)
  2. Monitor server performance during bulk email sends
  3. Optimize email templates for faster loading and better compatibility

By thoroughly testing your email functionality, you can ensure that your Ghost CMS is correctly configured to send both transactional and bulk emails via Mailgun. Regular testing and monitoring will help maintain the reliability of your email communications, improving user experience and engagement with your Ghost-powered website.

Key Takeaways

Configuring Ghost CMS to send emails with Mailgun is a crucial process that enhances the functionality and user experience of your website. Here’s a summary of the key points and best practices covered in this guide:

Understanding Email Types

  • Ghost CMS can send two types of emails: transactional and bulk.
  • Transactional emails are individual messages triggered by specific actions (e.g., password resets, account notifications).
  • Bulk emails are used for newsletters and mass communications with subscribers.

Mailgun Configuration

  1. Choose a subdomain for email sending (e.g., m.yourdomain.com) to protect your main domain’s reputation.
  2. Set up proper DNS records (SPF, DKIM, MX, CNAME) in your domain’s DNS settings.
  3. Verify DNS settings in Mailgun to ensure proper email authentication.

Ghost CMS Setup

  1. Configure bulk email settings in the Ghost admin panel using Mailgun API credentials.
  2. Set up transactional emails by editing the config.production.json file on your server.
  3. Use environment variables for storing sensitive information like API keys and passwords.

Best Practices

  • Regularly update SMTP credentials and API keys for security.
  • Monitor email deliverability and engagement metrics in both Ghost and Mailgun.
  • Implement proper error handling and logging for email-related issues.
  • Conduct thorough testing for both transactional and bulk emails after configuration.

Troubleshooting

  • Check Ghost and server logs for specific error messages related to email sending.
  • Verify Mailgun account status and sending limits.
  • Ensure all DNS records are correctly set up and propagated.

Ongoing Maintenance

  • Regularly audit your email configuration and update as needed.
  • Stay informed about changes in email standards and Mailgun’s features.
  • Continuously optimize email content and sending strategies based on performance data.

Security Considerations

  • Use strong, unique passwords for SMTP users and API keys.
  • Implement IP restrictions if possible to limit where emails can be sent from.
  • Regularly review access logs and email sending patterns for any suspicious activity.

Compliance

  • Ensure all bulk emails include valid unsubscribe links.
  • Comply with relevant email regulations such as GDPR and CAN-SPAM.

Performance Optimization

  • Monitor server resources during bulk email sends.
  • Optimize email templates for faster loading and better compatibility across devices.

By following these guidelines and best practices, you can effectively configure Ghost CMS to send emails using Mailgun, ensuring reliable communication with your users and subscribers. Remember that email configuration is not a one-time task; it requires ongoing attention and optimization to maintain high deliverability rates and user engagement. Regular testing, monitoring, and updating of your email setup will help you leverage the full potential of Ghost CMS’s email capabilities, enhancing your website’s functionality and user experience.

Leave a Comment


Get Dave’s News­letter

Stay ahead of the curve

Get Dave’s News­letter

Table of Contents