Members

Adding SMTP to your Contact Form in 2.0.2

Hey guys,

Just a short post for anyone experiencing problems with the contact form on their blog. 2.0.2 now comes with the option to use SMTP to ensure your mail gets through. This tip will assist you if you receive the “Could not instantiate mail function” error when testing your form. It looks like this:

If you see this, this post can help you.

This means that PHP and Sendmail are not working together nicely on your server, but do not despair. If you have an email account with anyone that provides you with SMTP access (Gmail, perhaps your own server, or even your Internet service provider) you may enter those details into your contact form to correct this.

Start by opening up the file contact_form.php in your theme folder (in my case wp-content/themes/OneTheme/contact_form.php), and scroll down until you see this section:

SMTP entry - commented out.

Now we have to uncomment the lines by removing the two forward slashes at the start of each line, and entering our SMTP details in-between the single quotes. As an example I will change the Username to ‘karl@one-theme.com’:

When you are done it should look more like this.

Thats really all there is to it! Save, and upload and as long as you entered working SMTP details your contact form should work like a charm.

Until next time!

Karlo

4 Comments

  1. #1
    Roddy Bisset
    October 7th, 2009 at 8:51 am

    Excellent Karl

    I have loaded v2.0.2
    I have downloaded contact_form.php
    I have input the gmail account details as per my account with gmail (removing the //’s)
    The form is here: http://www.etoiledumatin.ca/?page_id=738

    this is the error message I get.

    Warning: fsockopen() [function.fsockopen]: unable to connect to pop.gmail.com:25 (Connection refused) in /home/condo27/etoiledumatin.ca/wp-includes/class-smtp.php on line 122

    Post ReplyPost Reply
  2. #2
    October 7th, 2009 at 9:09 am

    Hey :)

    Gmail doesn’t use port 25 as standard as they use TLS encryption. You could try changing the port number to 465 or 587 as per the instructions here:

    http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

    Post ReplyPost Reply
  3. #3
    Tinh
    December 29th, 2009 at 1:28 am

    Yes, Gmai use port 465 and 995. Thanks

    Post ReplyPost Reply
  4. #4
    Africafreak
    February 5th, 2010 at 6:19 am

    Hi Karl, Jay!

    How are you guys doing??????????? :)

    Haven’t heard from you in a while, is everything ok? Is One Theme still alive?

    I must admit I’m getting a little worried…no more activity in the forums since October 2009…?

    If there is anything to announce, please let us know…

    Thanks,

    Michael

    Post ReplyPost Reply

Leave a Reply