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 bespoke 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 running 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 set up with the webserver.
The “Failed to send your error message” error arises because the web server, Apache or IIS, has not been configured to send out mail.
So we needed an alternative way to send out mail (SMTP) from WordPress.
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 activate 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 set up a new account under Outlook.
The plugin even allows 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 accommodate 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.
So that you can easily reply to customers submitting the forms, you need to add the following line into the Additional Headers field.
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 now get the “Your message was sent successfully. Thanks.” green bordered message.
Note: It may take a little longer for the email to arrive in your inbox as 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, remember 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.