Deliver Contact Form 7 Email with Mailgun for Free

Contact Form 7 is a widely used WordPress plugin for quickly adding forms to your site. If you’re running a lightweight setup, integrating it with Mailgun can easily enable reliable delivery of emails when users submit forms. Plus, if it’s for a non-commercial site, it’s free!

First, make sure you have the Contact Form 7 plugin installed on your WordPress instance. Then, sign up for a Mailgun account, which will allow you to send up to 10,000 emails per month free. If you ever want to send more emails than that, the cost of Mailgun is very reasonable, especially given how reliable it is. When signing up, you can bypass the payment settings (unless you want to add your card on file), and toggle the price meter down to $0 and verify it’s for non-commercial use. If you’re using it for commercial purposes, just add your card info and continue.

Once Mailgun is set up, they’ll send you an API key via email, but that’s not the key you’ll use when configuring WordPress. The trick is to use the sandbox domain for delivering email, so we’ll need to add your destination email address as an Authorized Recipient in Mailgun.

  • Click the Manage Authorized Recipients button.
  • Click Invite New Recipient and enter the email address that you would like the Contact Form 7 submissions to go to.
  • Once you receive the verification email from Mailgun, click the link to verify ownership of that email address.
  • Next, install the WP Mail SMTP by WPForms WordPress plugin.
  • Now, in WordPress navigate to the WP Mail SMTP settings and set the following values:
    • From Email
    • From Name
    • Mailer (Mailgun)
    • Private API Key – to locate, navigate to https://app.mailgun.com/app/domains, click the sandbox domain name, and locate the private key.
    • Domain Name (sandbox<unique-id>.mailgun.org)
  • Click Save Settings

Now, when you create a Contact Form, ensure the mail settings reflect the email address (the To field) that will receive the form submissions via Mailgun’s delivery. For good measure, I also set the From field to use the same email address.

I haven’t had any issues with email delivery, however you may want to whitelist the From sender in your email platform.

2 Replies to “Deliver Contact Form 7 Email with Mailgun for Free”

  1. I don’t understand why you use sandbox and not the actual domain. Is there any reasoning behind this?

    Sandbox is mostly for staging or testing environments, this is why it can only send emails to approved email addresses.

    1. Hi Tudor,

      Mailgun has since changed their pricing model. I might have done this originally to easily restrict delivery to a single address. I may post an update with production-level instructions.

Leave a Reply

Your email address will not be published. Required fields are marked *