Fix WordPress mail problem with Fasthosts and SMTP

Just go to the solution
This week I came across this lovely issue regarding a problem with WordPress sites hosted on Fasthost servers using email SMTP details. I was literally pulling my hair out trying to move an important client over between web hosts. If you’re reading this post, the chances are you’re in the same boat as I was, you may of already worked out that using WordPress built-in php mail() option works fine but we all know there can be issues with leaving it to your site to send out emails on your behalf. (Fine for smaller websites).

I’m in no way slating Fasthosts as they are one of the biggest and most reputable web hosting companies in the UK, they do provide brilliant services at premium prices. But their built-in user interface/dashboard isn’t quite clear enough or easy to navigate and looks like they got a bunch of developers to design the whole process.
Anyhow their live chat and support areas are good to a certain extent but neither of them could come up with the solution to my problem which led me on to try to find out what could be causing this issue with my contact forms not sending out emails/not authenticating. I knew this was working before on my previous host perfectly so it had to be down to my host and it’s configuration.

This fix could apply to other hosts out there that are having similar problems. I found out that it’s down to the way their server is configured and preventing certain ports and user criteria passing through their firewall. As Fasthosts wouldn’t budge I had to modify my site to work with them.

If using Contact form 7 plugin try this first:

The other suggested fix for this with WordPress not sending emails could be down to the plugin I was using ‘Contact Form 7’. This was by editing the classes.php within the ‘/contact-form-7/includes/’ folder.

Find this line of code: (roughly line 550 for me)
Always make a backup just in case something goes wrong and you can easily revert back.

$headers = "From: $sender\n";

And replace with the following:

$headers = "From $sender\n";

Now this didn’t work for me but it might for you… Reported through WordPress support and plugin support forums this fixed a lot of people’s issues so I thought I would add this in just in case.

How to fix wordpress SMTP mail problem with Fasthosts with the following plugins

WP-Mail-SMTP (wp plugin) – already installed

This plugin is installed and used to send all emails by SMTP rather than through the PHP mail() function. I’ll probably write-up a more detailed article on how to use this plugin at a later stage. Aslong as you have your details filled in correctly this works 9 out of 10 times and you can even run tests to make sure it’s sending correctly.

Please note: For Fasthosts, you need your email to be hosted or have an email ‘starter’ account set up (with Fasthosts) in order for the server to allow sending of emails from the WordPress site. I was trying to use SMTP details from Godaddy and they weren’t playing ball!

Make sure to have these settings (of which they supplied to me):

Mailer: Tick, Send all WordPress emails via SMTP

SMTP Outgoing:

SMTP Port: 587

Encryption: no encryption

The solution

WP Mail Options (wp plugin) – I had to install this to get it to work

Now, there’s so many settings in here which I didn’t have to touch… so I’ll list the ones that I added/edited to get it working.

Change the plugins settings to these:

Email priority: 3

Content Type: ‘text/plain’ – if sending plain text emails or ‘text/html’ – if sending emails with html inside.

From: Email address the same as your WP Mail SMTP email hosted on Fasthosts

From Name: Your name, website name or company

Sender (Return Path): Set as same as the ‘from’ field

Once all of these has been applied you should now have working contact forms that are sent via SMTP. Hooray!

I’m sure there will be some teething problems and this might not sort your issue out if slightly different. I do however strongly recommend that if you’re not sure on what you’re doing, speak to Fasthosts support first, although they were stumped and they wouldn’t allow any conditions for opening ports in their firewall, I managed to solve this myself and I’ve informed them of this fix to help others.

As always if you got any problems or issues shoot away below in the comments and I’ll see if I can help or maybe my post above isn’t clear enough.

Either way, your feedback is always welcome.