Fixing Contact Form 7’s “Failed to send your message” error

We came across this issue on a recent client website.  This blog will show you how to fix the issue.

The website was designed as a beskpoke theme running on top of WordPress 3.0.5, although the WordPress version number is not relevant to the fix.

A couple of forms on the site were used to collect enquiries and bookings, choosing Contact Form 7 to implement these (version 2.4.3 at the time of writing).

Our development environment is the standard WAMP/LAMP model (Windows/Linux, Apache, MySQL and PHP) where everything was tested and working fine.

The problem occurred when uploading the site to the hosting server which was runing IIS rather than Apache -although, IIS is not the direct cause of this issue.

When submitting a Contact Form 7 form we received the “Failed to send your message. Please try later or contact administrator by other way.” error message.

In most of the hosting options we’ve come across, we have found that Apache and IIS are configured to use the sendmail or equivalent program.

Any call to the phpmail() function, which is how WordPress sends its mail, is determined by how the php.ini file is setup with the web server.

The “Failed to send your error message” error arises because the web server, Apache or IIS, has not ben configured to send out mail.


So we needed an alternative way to send out mail (SMTP) fromWordPress.

A quick search of the plugins revealed a nice little plugin called WP Mail SMTP.  It does what it says on the tin!

You’ll need to download and active this plugin, then set it up with the relevant email address, that you use along with the outgoing mail server name, username and password.

Configure this plugin the way you would setup a new account under Outlook.


The plugin even alows you to send a test mail so you’ll know when all the details have been entered correctly.

Once your WordPress installation can send out SMTP mail you’ll need to alter the Contact Form 7 form templates slightly to accomodate the new method of sending mails.

In the From: field, enter the same email address that you have used to configure the WP Mail SMTP plugin.

This sets the senders email address on the outgoing email message.  You may have it setup with an info@ or webmaster@ address.

So that you can easily reply to customers submitting the forms, you need to add the following line in to the Additional Headers field.

Reply-To: [your-email]

Making sure to replace the field name ‘your-email’ with whatever field name you are using to gather the email address on the form.


This sets the reply address on the outgoing email message.  When you click on reply in your inbox your message will be sent to the email address that was entered in the form and not the one used to send out the email which you configured in the WP Mail SMTP plugin.

Hit the save button on the form, refresh your front-end contact form and try sending again.

You should nowget the “Your message was sent successfully. Thanks.” green bordered message.

Note: It may take a little longer for the email to arrive in your inboxas it is being routed through an additional step.  Give it a minute or so then check your inbox.

HTML option Note: If you have the “Use HTML content type” checked, remeber to remove the < and > characters from the default ‘<[your-email]>’ line that’s created otherwise it will look like the email address is missing from your incoming HTML messages.  The email client will try to render the address as an HTML tag because it’s included within the < and >.

Google Analytics Event Tracking: You may also like to set up Google Analytics event tracking for your forms.

Let us know if this has helped you.

  • Hey You!

    We'd like to know a little more about who's reading our stuff.

About Wil

Wil is a professional web developer with a passion for leading edge technologies, security and server architecture. He spoke at WordCamp Sydney 2012, co-organizes the WordPress Sydney meetup, was lead organiser for WordCamp Sydney 2014 and contributes to the WordPress Core development. He likes pizza, sausages, chilies, beer, red wine and hyperdimensional physics.

  • Groupable

    Thank you. There are a lot of these out there that don’t really intend
    to answer the question. The SMTP plug-in was exactly the right answer.

  • Faysal Hossin IMran

    Thanks a lot..

  • fhjdsakfjhdskjfh

    my problem was solved very easily by chainging the from and to addresses to my email.

  • Jesse Brownstein

    I am trying to test CF7 on local dev using InstantWP. It won’t send. Any ideas or starting points? Thanks in advance!

  • An Thraxan

    Thank you kindly for this!
    I just changed hosts, moved all my sites over and this happened. I tried reinstaling CF7 but to no avail. This worked instantly! Thank you :)

  • Don Graham

    Great post! Thank you for sharing your insight. Saved me a ton of time researching for a solution.

  • Gian Faye

    Thank you! This worked. :)

  • imran

    Hi will i am having the Same issue on iis i have tried to change email but wordpress not even send me a confirmation email what should i do

  • vivek

    Gr8 Post..Thank you for sharing your insight. Saved me a ton of time researching for a solution.


  • Brad Kirwan

    Hi Wil, great post mate, saved me so much time mucking about with CF7, which just stopped sending emails after working faultlessly for over a year. Well explained and I had my contact emails up and running again in 10 minutes. Many thanx.

  • Ramya Rao

    saved the day … worked like a charm

  • DK Paul

    Thanks a lot..

Inbound Marketing Certified
Realex Logo
Meetup Logo
AppThemes Logo
WordPress Australia
Sage Pay