Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Send Email in WordPress using the Gmail SMTP Server

Last updated on by
Follow WPBeginner on YouTube
How to Send Email in WordPress using the Gmail SMTP Server

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 &raquo Email.

WP SMTP Mail Screenshot

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:

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.

Download WP Mail SMTP Plugin.

Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • James

    I discovered a little change I would make to what was said by Marcus… I tried it with what he said, but it didn’t work for me using Bluehost… What I then tried, was using all the same things said above, and with the changes Marcus suggested, then in the settings for the wordpress plugin, I told it to use the account on the bluehost server with it’s server info and login info and it sent the email out with the right return path and when i reply’d to it, it went back to the gmail email account…

    Thanks for the start on getting this to work!

  • WPBeginner Staff

    Please checkout our guide on how to fix WordPress not sending emails issue.

  • WPBeginner Staff

    Yes, you may also want to take a look at how to fix WordPress not sending emails issue.

  • WPBeginner Staff

    Please take a look at our guide how to fix WordPress not sending email issue.

  • tomlewis

    Tried this first, but it failed to send, so I tried Easy WP SMTP instead, but this just gave me:
    SMTP connect() failed.

  • WPBeginner Staff

    Do you have access to the email address used in the form’s from field? If you do, then you need to find out the SMTP settings for that email address and use those settings instead of using your personal gmail account.

  • WPBeginner Staff

    Please contact your web host they may be able to help you better.

  • BigTone

    Okay I need some help. My website is with blue host. I use gmail. Once upon a time you could scroll to the bottom of my sites home page, go to the contact us section in the menu bar or click “get quote” from our pricing table on the plans & pricing page and successfully send us an email. Now, either method gets a green indicator that the messages was sent, but we never get the actual email in gmail. I tried installing this plug in and now all i get is an error message when i run the test email.. Can somebody help a fella out??

    The SMTP debugging output is shown below:

    SMTP -> ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0)

    • WPBeginner Staff

      1. Gmail has a known issue which does not allow you to send email to the same email address using SMTP server. Try sending a test email to some other email address.

      2. Make sure your username and password are correct. Your username is usually your complete email address like

  • WPBeginner Staff

    Try changing SMTP port to 587 and in the Encryption: use TLS encryption.

  • Eduardo Capanema

    Works perfectly, thanks!

  • Shane Wlbur

    I am trying to use this plugin with woocommerce.
    It is failing to configure the permalinks correctly as woocommerce has different permalinks that normal posts and pages?
    What can be done to make it work?
    My site is at
    Have a look please

    • WPBeginner Support

      Shane we can not understand your issue. The plugin mentioned in this article has nothing to do with permalinks.

  • Sanskar

    My website is on bluehost. Although I use Windows live domains to handle my emails, I created a bluehost email from Cpanel ( to avoid that ugly admin email. Now the problem is that these emails, when generated by wordpress, are ending up in spam folders. Can I use this method of Gmail SMTP server to avoid emails ending up in spam?

    • WPBeginner Support

      Yes you can.

  • Zakaria

    There are many nice plugins for these purposes. For example (( WP Mail From II )) very easy, perfect for beginners.

    Best regards
    Good luck!

  • Moeen

    Help me with this error
    SMTP -> ERROR: Failed to connect to server: Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP? (0)

    • WPBeginner Support

      Please contact your web host. It seems like PHP is not configured to use SSL extension.

  • Gary D

    The WP Mail SMTP plug-in mentioned works with a test mail, but I use a program called “Spreadsheet converter” that converts a spreadsheet into html/java.
    The html and support java files are then saved to the same web server and domain, but not into that particular wordpress page itself.
    The calculated html/java page is displayed within an iframe on a wordpress page.
    The results are brilliant and so are the live data charts.
    Until I come to submitting the form created.
    The program wants to know what URL is used to process any form it creates.
    I want to test the forms on localhost, before sending the site live.
    So my question is….
    Where do I tell the program to find the url that processes the form and sends it as an e-mail?
    I am fumbling around trying different *.php files to see if they work.
    But I get error messages or a blank screen.

    Can you help?

  • tan

    its working for me great!!

  • tonisha

    I installed and hit test and received this response…

    Test Message Sent

    The result was:


    The full debugging output is shown below:

    • Jainam

      Did you solve this error i get the same error…

      and i don’t know how to solve this error if you solve please reply..

      Thank You.

      • Aaron Pook


        I am also facing the same problem. Any solution?

        Please advise.


  • Salman Jaleel

    Hello Sir,
    I am running a blog on wordpress 3.7.1 using a free ftp service on and it doesn’t have smtp server to send emails .. so I am wondering if there is an alternative way to send emails to my blog users .. because wordpress do send an email containing passwords at the time of registration, and users are not getting any email on their personal email accounts .. So kindly help me to get out of this problem! please do let me know at ( .. Thanks..

    • WPBeginner Support

      Salman, did you try installing WP Mail SMTP plugin? After installing the plugin set it up to use Gmail SMTP and this should work. However, if it does not work we would recommend you to use a better WordPress hosting provider.

      • Salman Jaleel

        Sir, I tried it too, and it shows connection time out .. and thanks 4 advice :)

  • Rohith Kumar

    Hi Author.

    your article is very useful.

    i have and .org account, so i want to use to send mail’s in my wordpress.

    how to do that ?
    what is the SMTP Details.

    Thanks in Advance !!!


  • naqqashrana

    sir i want to confirm that may i use this method on localhost

    • WPBeginner Support

      yes you can.

  • Jo

    I just want to say I love you so much, this article was really straight forward and easy to follow! This has been bugging me for days and you helped me make it work!!! :) :) :)

  • Ian Harris


    I am have built some custom template pages in wordpress with some forms. I normally use a SMTP script to handle this form and send the lead through. But this doesn’t work in wordpress. The mail function is too dodgy so want to use SMTP.

    So i install the plugin? but what do i put as the method=”” for my form?? surely this needs to point to the appropriate script for it to work?

    Please help asap



  • Myrko Thum

    Gmail doesnt work for me as SMTP host. I always get:

    string(35) “SMTP Error: Could not authenticate.”

    And gmail informs me that someone tries to use it. I confirm it was me, password etc. is correct.

    But it wont work.
    What can I do to make your method work?

  • khan

    worked for me aswell

  • Sebastian Leal

    Excellent works like a charm!

  • Luan Tran

    Should I use hosting server to send mail or use another SMTP server like Gmail. My blog take too much time loading when someone post comments.

    • Editorial Staff

      We’d recommend using another SMTP server like Gmail.

  • mjmohebi

    I did just what you said and it worked perfectly.

  • bharathvn

    Excellent!! Thanks

  • Terry

    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?

    • Editorial Staff

      Not sure what could be going wrong. Perhaps ask the plugin author to take a look.

  • Andrea

    Thank you it worked perfectly.
    I own a VPS and using this way decrease probability of getting hacked ;-)

  • Tevya

    Anyone know if this works with WP 3.5.1 running Multisite?

    • Editorial Staff

      Haven’t tried it, but don’t see why it wouldn’t.

  • julielabruyere

    Thanks a lot for your explanations, I was starting to cry before getting to your post!

  • Katja Nevalainen


    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.

  • shawn

    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?

    • Editorial Staff

      Not sure why that is happening. We haven’t noticed it on our servers.

    • javier

      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

    • javier

      its me again, sorry the line you have to add to the spf is
      that way your email address its not blocked by spam filters. cheers

  • Jonathan M.

    I’ve got an account on Hostmonster (Bluehost reseller) with Google Apps for email on the same domain. I created a 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!

  • Jonathan Manness

    Thank you, WPBeginner! For some strange reason, my contact form stopped working and your solution works perfectly!

  • Matevz Spacapan

    This got the Google account disabled :P 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 =)

  • gleenk

    @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…

    • marcuswickes

      @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,

      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).

  • wpbeginner

    @gleenk Did you put the right host information? and your account info?

  • larry.wilcox

    The SMTP issue only needs to be addressed if you use the custom URL feature for Google Apps and change your mail URL from to for example. Then you do indeed need to set up CNAME record and a bogus email address.

  • gleenk

    It doesnt’ work for me, neither with marcus tricks. I receive:

    “string(43) “SMTP Error: Could not connect to SMTP host.”

  • marcuswickes

    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.

    • Mojowen

      @marcuswickes This worked great, thank you for the tip

    • Jonathan M.

      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 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.

    • Anne

      Thanks for the info Markus – i use dreamhost and it won’t let me set up a duplicate email because I am using google apps ( It says, email is being handled by google apps. It seems that for email, I can only use google apps OR dreamhost , but not both. So, any ideas what to do?