Using Mailgun to set up transactional and form emails in Wordpress Print

  • 0

How to Configure Reliable WordPress Emails with a Free Mailgun Account

By default, WordPress attempts to send password resets, contact form submissions, and WooCommerce receipts using your web server's native PHP mail function. To protect our network reputation and ensure your emails actually reach the inbox, Eastern Shore Web Services requires all WordPress sites to send transactional email through an authenticated external provider.

This guide will show you how to set up a free Mailgun account (which includes 100 free emails per day) and connect it to your WordPress site using the free and highly secure FluentSMTP plugin.

Prerequisites

  • Access to your WordPress admin dashboard.
  • Access to your cPanel account to manage DNS records.
  • A registered Mailgun account.

Step 1: Set Up Your Free Mailgun Account

Mailgun offers a perpetual free tier that allows up to 100 emails per day, which is perfect for standard website contact forms and notifications.

  1. Go to Mailgun.com and sign up for an account. (You may need to enter a credit card to verify you are human, but you will not be charged if you stay under the 100/day limit).
  2. Once logged in, navigate to Send > Sending > Domains.
  3. Click Add New Domain.
  4. Important: Do not use your root domain (e.g., yourdomain.com). Instead, use a subdomain specifically for website routing, such as mg.yourdomain.com or send.yourdomain.com.
  5. Select your region (US or EU) and click Add Domain.

Step 2: Add Mailgun DNS Records in cPanel

Mailgun will now provide you with a list of DNS records (TXT, MX, and CNAME). You must add these to your web hosting account to prove you own the domain.

  1. Log into your cPanel dashboard.
  2. Scroll down to the Domains section and click on Zone Editor.
  3. Click the Manage button next to your primary domain.
  4. Use the + Add Record button to carefully copy and paste each record provided by Mailgun:
    • TXT Records (SPF & DKIM): These authorize Mailgun to send on your behalf.
    • MX Records: These handle bounce reports for the subdomain.
    • CNAME Record: This enables open and click tracking.
  5. Return to the Mailgun dashboard and click Verify DNS Settings. (Note: DNS propagation can sometimes take up to 24 hours, but usually completes within 15 minutes).

Step 3: Generate Your Mailgun API Key

Connecting WordPress to Mailgun via an API key is significantly faster and more secure than using traditional SMTP credentials.

  1. In your Mailgun dashboard, click your profile icon in the top right and select API Security.
  2. Scroll to the Mailgun API Keys section.
  3. Click Create API Key.
  4. Name the key something recognizable, like "WordPress Website API".
  5. Copy the generated key immediately and save it in a secure location. You will not be able to view it again.

Step 4: Install and Configure FluentSMTP in WordPress

Now that your Mailgun account is ready, you need to tell your WordPress site to use it.

  1. Log into your WordPress admin dashboard.
  2. Navigate to Plugins > Add New.
  3. Search for FluentSMTP, then click Install Now and Activate.
  4. Go to Settings > FluentSMTP and click on the Mailgun icon to configure the connection.
  5. Fill in the following details:
    • From Email: Enter the address you want emails to appear from (e.g., noreply@yourdomain.com). Check the "Force From Email" box.
    • From Name: Enter your business name. Check the "Force From Name" box.
    • Domain Name: Enter the subdomain you created in Step 1 (e.g., mg.yourdomain.com).
    • API Key: Paste the API key you generated in Step 3.
    • Region: Select the region you chose during your Mailgun setup (US or EU).
  6. Click Save Connection Settings.

Step 5: Send a Test Email

To verify everything is working perfectly:

  1. Inside the FluentSMTP settings, click on the Email Test tab.
  2. Enter your personal email address in the "Send To" field.
  3. Click Send Test Email.
  4. Check your personal inbox. If the email arrives, your WordPress site is successfully configured to route transactional emails safely and securely!

If you encounter any routing errors or need assistance adding your DNS records, please open a support ticket through your billing portal.


Was this answer helpful?

« Back