How to send email in WordPress using Gmail’s SMTP server

Well this question was asked to me for more than a couple of times now. So I thought of documenting it here, instead of answering them individually. 🙂

Long time readers of my blog would know that I use Google App for email. Ever since I moved to Linode for hosting, I stopped running a mail daemon in my server, and instead choose to use Gmail’s SMTP server for sending email.

There were two reasons for it. First most email providers ignore or mark as spam, emails sent from non-SMTP servers. Second, removing mail daemon from server will save some resources and will increase the over all performance of my server.

Using SMTP in WordPress

For WordPress there is an excellent Plugin called WP Mail SMTP, which can be used to send email through Google’s SMTP servers.

Download and install the Plugin and in the settings page you have to set the following options.

  • SMTP Host:
  • SMTP Port: 465
  • Encryption: Use SSL encryption
  • Authentication: Yes
  • Username: Your full Gmail address or Google App email
  • Password: your account password

You can also checkout the following screenshot for reference.

using gmail smtp in WordPress

I am also working on a Plugin to log all emails sent by WordPress. Expect it to be released soon 🙂 (Update: The Plugin to log all emails is ready. It is called Email Log and you can download it from the Plugins page.)

Update (Oct 2012)

I just realized that these days Google has added additional security for logging in using other clients. If your email is not sent properly after giving correct password, then refer to instructions at Gmail help to fix it.

Also if you have enabled two factor authentication, then refer to this Gmail support page.

Related posts

Tags: , , , ,

59 Comments so far

Follow up comments through RSS Feed | Post a comment

  • Scott says:

    how is the smtp log plugin going?

  • IwingMusic says:

    it doesn’t work anymore with wordpress 2.9

    • Sudar says:

      Are you getting any specific error message.

      • IwingMusic says:

        Sorry, actually it was crashed during upgrading but it has fixed now. And I use Joomla now, I’ve done with WordPres, hehe..
        Btw, you don’t need to use plugin as to it will decrease website performance. Just configure wp-includes/pluggable.php and class-phpmailer.php.

        I think Joomla is more fast than WordPress and has more function, ;-).

        • Sudar says:

          “I think Joomla is more fast than WordPress and has more function”

          This is a very subjective sentence and I will not get into it 😉

          The reason why we should use a Plugin instead of changing wp-includes/pluggable.php is because, you don’t need to worry about it while updating WordPress. When compared with Joomla, WordPress get’s update pretty frequently 🙂

          • IwingMusic says:

            When compared with Joomla, WordPress get’s update pretty frequently 🙂

            Absolutely right, that’s why I use Joomla :-D. Well i just need another experience indeed.

            While new version of WordPress comes up there are usually some bugs or errors like one I’ve posted in WordPress forum about Category Slug. Maybe that’s why they always go with updates ;-).

            However WordPress is the #1 opensource, because everybody uses it, phew.

            • Craig Kelley says:

              I would strongly disagree. Not only is the Joomla interface hard to use but the plugins are heavy and slow everything down. Transferring from one server to another is a nightmare. The only thing that annoys me more at this moment is this auto pop-up on every word in this box. Wow, i would never torture a user with this.

  • miki says:

    Nice I will try it with google apps

  • Shammi says:

    HI there

    Thanks for the post this was good i did figure out early how to use smtp host i am using google aps but i missed out on the port and was using 587 to and i guess that was closed by my host i figured out here that i should try normal ssl and it just worked

    I am using c-formII pretty with wp and google apps.

    ssl enabeled – port 465

    username and pass it works like a cake


  • ken says:

    just wondering..
    wordpress is suppose to be able to send email notifications without the need of a plugin right?
    so why must one go through this configuration to get wordpress to send emails?
    is it because of the webhost?

    p/s: im hosting a wordpress blog but it doesnt seem to send emails out whenever i get comments to be moderated, backup to email as well.

    thank you in advance!

    • IwingMusic says:

      Yes if you have sendmail feature enabled on your webhosting service.

    • Sudar says:

      If you already have sendmail (Email Server) running on your web server, then you don’t need to install this Plugin or configure anything.

      But if you don’t have sendmail installed or don’t want to use it and instead want to use your Gmail or Google Apps account to send emails then you have to configure using the above instructions.

  • Techlook says:

    thanks… now i can use sendmail with google application..

  • Marion Orosa says:

    Wow that you for that, although I pretty much connect my google to my outlook^^

  • nuig says:

    how can I post to wordpress via gmail please.
    I cant work it out

  • Abraham says:

    Thanks for the TUT.

    But is there a plugin that can do this:

    1: Let me compose and send an email to one of the authors of Self Hosted WordPress blog
    2: Let me compose the email from Make/Edit Post Page of Admin Panel.

    Many thanks for the help.

  • Wordpress Integration says:

    wordpress is suppose to be able to send email notifications without the need of a plugin right?
    so why must one go through this configuration to get wordpress to send emails?
    If you already have sendmail (Email Server) running on your web server, then you don’t need to install this Plugin or configure anything.

  • Simon says:


    I get the mails from wordpress whenever I get a comment no prob but I have a related question.

    I have different forms on the blog that I want them to send info to different emails than the admin one. Is there an option I didn’t see or is this impossible (doubt it).

    The emails are actually mailing lists hosted on my school’s server.

    Any ideas?

  • Scott Elkin says:

    I just noticed my google analytics had hundreds of people hit my contact page, but that I wasn’t getting any email.

    I tried to get it working w/ my apps email, but gave up before trying the port you used.

    Thank you so much! Seriously awesome.

  • Mariano says:

    Hello! Is this pluggin working in 3.04 version?

    Becouse it sends me an error in the test. Says “Couldn connect to smtp server”

    And all the parameter (, port, ssl, username(full qith and password ) are ok.

    Any idea?

    • Sudar says:


      I guess the Plugin is compatible with 3.0.4 as well. Try to see if your server admin has enabled making SMTP connections from your server.

  • Great article!. Thanks.

  • id meneo says:

    I tried to use this trick but it is not working for me… maybe I did something wrong.

  • ning says:

    thanks for sharing!! appreciate it!!! =)

  • Sam says:

    You screw Gmail if you do that. You get:

    We’ve detected unusual activity on your account. To immediately restore access to your account, choose how to verify your account.

    For your security, we strongly recommend running anti-virus software on your computer to detect and remove any malware.

  • Mateus says:

    is it possible to use this to “open my gmail account” in a link in my website?
    example: I have a site and a email account
    and I just want a link/button that allows me to open my email, without having to
    open a new browser window and typing the user and password.

    hope you understand me.


  • aminfosystems says:

    Thank you so much for the help!

  • Ajmal says:

    Hello Sudar.. Wanted to ask is there a plugin or will ur plugin help in – integrating a email server along(zimbra, roundcube, etc) with wordpress users.. ?

  • Ajmal says:

    Thanks Sundar… What I meant was — having all users a email system like a email server.. saying we make a roundcube or a zimbra server and then connect it to wordpress so that all wordpress users will automatically have a email account…. Is that possible

  • matt says:

    I’m having some problems with this – I’ve done everything mentioned, but when I send a test email it is received in my gmail account but doesn’t get published on my blog. Any idea why? Thanks for any help

  • Mike P says:

    Can Contact Form 7 use SMTP? How, what must I do? Something about changing “mail()” to “wp_mail()” … but where do I find “mail()” to edit and change?

  • mallory says:

    hi! thanks so much for the information, i’m wondering two things (and i’m *VERY* wordpress/techy challenged).

    1. the email plug-in for gmail, when i send an email will it read as (makemsayom being my website)? but the interface will come up as the same I use for gmail now, correct?
    2. the plug-in you have for your social network sharing (facebook/twitter/linkdin) in the heart shapes, whats the name of that plug in? it’s perfect!!!

    thank you so much for your help 🙂


  • agen bola says:

    I’ve tried your suggestion, but it still returns
    404. Page not found.
    Sorry, but you are looking for something that isn’t here.

  • From where i can use wordpress email function?

  • skylar says:

    I can’t get this to work I keep getting:[“language:protected”]=>
    array(17) {
    string(54) “You must provide at least one recipient email address.”
    string(25) ” mailer is not supported.”
    string(19) “Could not execute: ”
    string(36) “Could not instantiate mail function.”
    string(35) “SMTP Error: Could not authenticate.”
    string(35) “The following From address failed: ”
    string(45) “SMTP Error: The following recipients failed: ”
    string(30) “SMTP Error: Data not accepted.”
    string(43) “SMTP Error: Could not connect to SMTP host.”
    string(23) “Could not access file: ”
    string(33) “File Error: Could not open file: ”
    string(18) “Unknown encoding: ”
    string(15) “Signing Error: ”
    string(19) “SMTP server error: ”
    string(18) “Message body empty”
    string(15) “Invalid address”
    string(30) “Cannot set or reset variable: ”
    string(0) “”
    string(0) “”
    string(0) “”

    The SMTP debugging output is shown below:

    SMTP -> ERROR: Failed to connect to server: Connection timed out (110)

    SMTP Error: Could not connect to SMTP host.

  • neofreddy says:

    It’s possible to use two-factor authentication?

  • rakesh ramnani says:

    I am using wp mail smtp plugin.

    I have set up setting as bellow

    SMTP :
    PORT: 465
    Encryption : SSL

    Tick yes on authitication and provided my gmail account username and password.

    But when i test the this setting in below tab, it does not send email it showing following message

    “SMTP Connect() Failed” in Error info.

    I have also checked some other smtp settings.

    my wordpress site is published at localhost:8080/wordpress

    Please provide some help on this

  • thank you about this article

  • john says:

    Can we use gmail SMTP to send a mail from WP 4.2.2 version?

  • Shirlene Spillane says:

    Invaluable comments ! I Appreciate the facts ! Does anyone know where I could find a template a form copy to fill out ?

  • migomail says:

    amazing article..thank you

2 Tweetbacks so far

5 Trackbacks/Pingbacks so far

Leave a Reply

Your email address will not be published. Required fields are marked *