Thursday, August 1, 2013

How to send emails in Wordpress with Contact Form 7

Recently I was working with a client's Wordpress-based site where they had configured a contact form using Contact Form 7 to send emails to clients. I'm not going to enter in details on how to use Contact Form 7 since there are good guides in the plugin's site.

The thing is that after configuring Contact Form 7, I found issues sending emails. The Contact Form 7 owner posted a link to a blog that explained how to solve this for specific configurations using WP-Mail-SMTP plugin. This gave some guidance but I had to tweak it a lot (for example, changing from WP-Mail-SMTP to WP-SMTP) to make it work for me, and I hope with the following instructions you will be able to solve it in your site too.

First of all, my configurations:
  • Wordpress, version 3.5.2
  • Contact Form 7, version 3.4.2
  • WP-SMTP, version 1.1.5
  • The site is hosted in GoDaddy.
Notice that I use WP-SMTP instead of WP-Mail-SMTP.

First, you have to change the WP-SMTP configuration. You can do it through Settings -> WP-SMTP. Set the following:
                From: my email (ex: "asdf@gmail.com")
                From Name: "Whatever you like"
                Host: localhost
                SMTP Secure: None
                Port: 25
                SMTP Authentication: No
                All the other fields empty. 

WP-SMTP Configuration

You should be able to send a test email using the fields at the bottom of the form. If this works, you're almost done!

Finally,  another problem that I found is that you cannot send empty message body in the Contact Form (notice the [your-message] value in the picture below). Based on the Contact Form Docs, I configured the contact form as shown. The field [email-88] is the name of the field email that the user introduced in the form.

The reply-to header was a nice touch that I took from Mario Varga's post.

Contact Form 7 Configuration
Hope it works for you!

19 comments:

  1. You will need to make fake email ID for facebook or for anyone if you want to tell anyone your personal email id then you will need to make fake email address using this
    get anonymous email

    ReplyDelete
  2. I set up everything like you said and it still does not work!

    http://www.portlightadventures.com/main/

    ReplyDelete
    Replies
    1. What error is it showing? Do you have access to the logs? Can you post it?

      Delete
  3. I have same Issue

    SMTP -> ERROR: Failed to connect to server: Connection refused (111)

    ReplyDelete
    Replies
    1. Me too! Please help!

      Delete
    2. Can you please post the logs?

      Delete
  4. I'd like to know how can I change "from" from "Test Email" sender name. Currently it only works with "Wordpress" sender.

    ReplyDelete
    Replies
    1. I don't get it. What are you trying to achieve?

      Delete
  5. First available with WordPress Edition 2.8, this design tag profits the information of a tag. A tag ID can be approved as a parameter, but if no tag ID is approved, the information present queried tag will be came back.Because WordPress connections with this data source by itself, you as an end customer, shouldn't have to fear much about its framework.

    ReplyDelete
  6. thank you, I was banging my head on the wall, that extra line on the headers solved it. I owe you a beer!

    ReplyDelete
    Replies
    1. hahaha that's awesome! I'm glad it worked for you too!

      Delete
  7. thank you very much! you saved my day

    ReplyDelete
  8. It worked, thank you for the great post!

    ReplyDelete
  9. You can do this and not worry about all the extra settings:

    Log into your cPanel and hit MX Entry > Email Routing > Remote Mail Exchanger (instead of Local Mail Exchanger). If you do not have access to this setting you can call Godaddy and ask them to do it.

    ReplyDelete
  10. thank you because honestly I just found this great trick

    ReplyDelete