Recently we had an issue with one of our clients’ Gravity Form on their website. The data wasn’t being passed on to their Google Apps account email because WordPress doesn’t use SMTP mail like Google. Rather, the wp_mail() function makes use of the standard PHP mail() function which was trying to send to the address located on our client’s server. Now this is not entirely WordPress’ fault because on our servers it worked fine. So this also had to do with how their emails were setup on that specific server. Long story short, in order to resolve this issue we installed a simple plugin that would reconfigure the wp_mail() function to use SMTP mail. This made it possible to send all incoming data from the Gravity Forms directly to their Google Apps account. In this article we are going to show you how to install WP Mail SMTP Plugin for WordPress so you can send email using the Gmail SMTP server.
Note: for those running on shared hosting like Bluehost, Host Gator etc, make sure you check out MarcusWickes comment.
Firs thing you need to do is install and activate the plugin WP Mail SMTP. Upon activation the plugin adds new option under your Settings tab: Settings » Email.

If you click on that, it will bring you to a screen that allows you to configure all of your mail settings. At the top you will have a place to input which email you would like to use as a sender. If you leave that blank, then the default site email will be used. The name field can have your name or your site’s name. This will be shown as the person who is sending it. Make sure you select send all emails via SMTP.
The SMTP host and port are already predefined in the image for Gmail. For your convenient, here they are below:
Host: smtp.gmail.com
Port: 465
You can set which type of Encryption you want. This may vary depending on your server settings.
Click save and you are good to go. Before you do anything else, there is the option at the bottom of the screen to send a test email. You should do this to make sure that everything is working properly.







Hi
I did just what you said and it worked perfectly.
thnks
Excellent!! Thanks
I have checked the settings a thousand times and cannot get this to work at all. Debug keeps saying that “mailer is not supported”. Am using google apps email, ports, passwords, application passwords are all correct. Any ideas?
Not sure what could be going wrong. Perhaps ask the plugin author to take a look.
Thank you it worked perfectly.
I own a VPS and using this way decrease probability of getting hacked
Anyone know if this works with WP 3.5.1 running Multisite?
Haven’t tried it, but don’t see why it wouldn’t.
Thanks a lot for your explanations, I was starting to cry before getting to your post!
Hi,
odd, but it doesn’t sent even test mail to gmail, but to email services it send mail. I’m trying to use Newsletter plugin and send newsletters to recipients, but gmail doesn’t work at all.
This works perfectly for me but the problem I have is all my emails to clients go straight to their spam folder.
my email address with gmail matches my website domain name.
I have checked ALL blacklist / spam registries and both my domain name and ip block are perfectly clear with no warnings anywhere.
If I send email using my gmail browser, then my email goes straight to everyones inbox just fine.
It is only when sending email using my server that it goes to their spam box and this happens on every single email I send via my server.
How do I solve this problem?
Not sure why that is happening. We haven’t noticed it on our servers.
Thats because your dns txt records for the spf aren’t configured to accept email sent from gmail on behalf of your domain.
You must add something like this to your domain txt records for spf
include:smtp.gmail.com
its me again, sorry the line you have to add to the spf is
include:google.com
that way your email address its not blocked by spam filters. cheers
I’ve got an account on Hostmonster (Bluehost reseller) with Google Apps for email on the same domain. I created a wordpress@mydomain.com email account in the CPanel and use it to send emails with. I followed MARCUSWICKES notes and set Email Routing to Remote Mail Exchanger (look under Email > MX Records). Then I put the Hostmonster email and SMTP authentication in the WP MAIL SMTP plugin settings. I left the MX records for Google Apps the way they were and it works perfectly.
Let me know if you have any questions!
Thank you, WPBeginner! For some strange reason, my contact form stopped working and your solution works perfectly!
This got the Google account disabled
I really wonder why(info was correct and when I sent the test mail it got disabled). Anyway I sent Google a email hopefully they’ll enable it again =)
@wpbeginner Of course. I don’t know what’s the problem. I’ve asked to my host now to verify if it could be server problem…
@gleenk You may need to change your host information from wpbeginner’s example above. I should have mentioned in my reply that since I am “faking” my emails going through bluehost I actually have to use my bluehost box number as the smtp host (for example, boxXYZ.bluehost.com).
Then make sure your email and password are the settings from the email you set up in bluehost and NOT your google apps password (unless of course they are the same thing which I don’t recommend).
@gleenk Did you put the right host information? and your account info?
The SMTP issue only needs to be addressed if you use the custom URL feature for Google Apps and change your mail URL from http://mail.google.com/a/domain_name.com to http://mail.domain_name.com for example. Then you do indeed need to set up CNAME record and a bogus email address.
It doesnt’ work for me, neither with marcus tricks. I receive:
“string(43) “SMTP Error: Could not connect to SMTP host.”
If I might interject, I actually found there are more steps required if you are using some shared hosts like Bluehost.
If you have installed the plugin and followed the directions above and still don’t receive emails, you might try the following steps. I’m not sure on how all the technical pieces work so my explanation may not be top notch… but I know that these steps work since I use them on 20+ wordpress installations on bluehost accounts:
1. Log into your cPanel account and create an email account that matches your google apps email address (I know… it seems strange since you are not going to use it, but this step will essentially trick the server into believing you are sending the email through the same server)
2. Then in the cPanel account find your MX records and change the MX routing from automatic to “Remote”… it may be a little trickier to find now since they upgraded some UI functions inside cPanel but look for a small link next to MX that says “Email Routing: Remote Mail Exchanger more »”
3. Log back into your wordpress site and send a test email through the WP Mail SMTP plugin
Hope that works for you. This solution took me months of trial and error, literally hundreds of hours with tech support and outsourcing consultants, and a lot of caffeine and cursing. But I can now have forms like gravity forms on a wordpress installation on bluehost send an email to a google apps email address.
@marcuswickes This worked great, thank you for the tip
Your not tricking the server at all here. It is actually sending the mail with the local email account you created in your cPanel. You’ll also have to make sure and use the SMTP credentials for that email address you created in the cPanel. Looks like you got lucky and managed to have the same credentials on Google Apps and Bluehost.
Changing the email routing to remote only forces your hosting server to look at your domain MX records instead of automatically directing it to a local inbox the server thinks you have since the email address shares the same domain as the website.
Since your actually using a different email account, I think it would make more sense to make an address in cPanel with another name (I used wordpress@mydomain.com as I mentioned in another comment).
Bottom line is Bluehost like hosting companies don’t out-of-the-box support sending email and /or connecting via SMTP to Google Apps that use the same domain as the website. They are always going to try to direct the email/SMTP connection to a local inbox.