WP-ContactForm on Windows Host

The Enhanced WP Contact Form plugin for Wordpress is one of a few handy contact forms that are easily to added to your wordpress site. However, if you try to use it on a wordpress site hosted on a windows server you may get an error massage similar to the following when you hit the 'submit' button on the contact form:

Warning: mail() [function.mail]: SMTP server response: 501 5.5.4 Invalid Address in \wp-content\plugins\enhanced-wordpress-contactform\wp-contactform.php on line 178

It turns out that the windows mail transport does not like the friendly from email address that the plugin specifies, e.g.

From: webmaster <webmaster@pridedesign.ie>

it doesn't like the bit in the angled brackets <>, nore does it like the spaces.

So, one way to fix the problem is to quickly edit the plugin and remove the offending part from the 'From:' header. To do this:

1.) Go to your wordprss admin screen
2.) Click on the 'Plugins' tab
3.) Find the plugin called 'Enhanced WP-ContactForm', and click 'Edit'
4.) In the displayed code, find the line similar to:

$headers .= "From: $name <$email>\n";

5.) Edit this line and remove the <$email> bit so that you just have something like:

$headers .= "From: ".str_replace(" ", "_", $name)."\n";

6.) Now that we have removed the email address from the 'From:' field we need to add it somewhere else in the message, so find the line similar to:

$shortmsg = "$name ($website) wrote:\n";

7.) Edit this line and add the from email address (stored in the variable $email), somthing like:

$shortmsg = "$name ($email, $website) wrote:\n";

8.) Hit the update button and test your contact form, and if the wind's behind you, then you should now no longer get the above error message and everything should work perfectly!

Note: to use this contact form in wordpress in Windows (or any other email based functionality) you will need to install one of the few plugins that lets wordpress send emails via SMTP, something like the Swift SMTP plugin.

Stranger
Stranger's picture
That's very helpful, thanks

That's very helpful, thanks very much!

Joined: 21/05/2009
User offline. Last seen 1 year 40 weeks ago.
I never tried it on windows

I never tried it on windows hosting before but I was going to so now I know what to expect. Thanks for keeping us posted on this WordPress ContractForm issues.

Stranger
Stranger's picture
Good site

Thanks! I was looking for it!

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can use BBCode tags in the text.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.

Pride on FacebookPride on TwitterPride on TwitterPride on Twitter

Join Our Newsletter

* indicates required

Irish Internet Association

finalist.png
phone-number.png