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 Receive WordPress Emails from Localhost

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Receive WordPress Emails from Localhost

When using WordPress on localhost, you may come across situations where you would need to receive an email generated by WordPress or a plugin. By default, the mail functionality is not enabled on WAMP or MAMP on Mac server stacks. However, you can configure them to use Gmail SMTP server but this would require messing with the configuration files. In this article, we will show you how to receive or send WordPress emails from localhost.

Video Tutorial

If you don’t like the video or need more instructions, then continue reading.

First thing you need to do is install and activate WP Mail SMTP plugin on the WordPress installation on your local server. After activation, go to Settings » Email to configure the plugin.

The first option on this screen is the ‘From Email’, you need to enter your Gmail email address here. The next option is From Name which will be used as the name of the sender in outgoing messages. You can enter ‘WordPress’ here. This will make it easier for you to recognize an email. The third option on the screen is for choosing a mailer. The default php mail function will not work on most local server environments without configuring it. So you need to choose ‘Send all WordPress emails via SMTP’.

Setting up WordPress on Localhost to use Gmail SMTP server

Now you need to configure the plugin to use Gmail’s SMTP server to send mail. In the SMTP server field, enter and for the port field use 587. For the encryption option you need to choose TLS. Lastly, you need to click on Yes next to authentication, you would need to provide your complete Gmail address, e.g. and your Gmail password.

Adding Gmail SMTP Server details in WordPress on Localhost

That’s all. You can now click on Save Changes button to store your settings. Once your settings are saved, scroll down to the bottom of the page and try sending a test message. After sending yourself a test message, you can check your inbox to see if you have received the message and everything is working fine.

We hope this article helped you receive WordPress emails on localhost. For questions and feedback please leave a comment below or join us on Twitter.

Editorial Staff at WPBeginner is a team of WordPress experts 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 »


  1. mukesh says:

    i m mukesh
    this is too good

  2. surati says:

    not work so work for me thnq…

  3. Maksym says:

    Works very good! Thank you :)

  4. Steve says:

    You have to go into your Google account and turn on the feature “Sign In & Security > Connected Apps & Sites > Allow Less Secure Apps > ON”.

    • Warren says:

      Hi Steve

      What’s the navigation to get to the sign in and security > connected apps etc? Loads of tabs on the top once in settings, each with multitude of options.

  5. saurabh says:

    awesome..blowsome.. worked!!
    make sure your gmail has access to third party apps to send email.nothing else is needed than this video. good work . loved it.

  6. Pam Marshall says:

    Just what I needed to do my testing.

  7. Roger Moore says:

    I worked well after I enable access to less secure apps in my gmail account. Thanks

  8. Chetan Buddh says:

    array (size=18)
    ‘authenticate’ => string ‘SMTP Error: Could not authenticate.’ (length=35)
    ‘connect_host’ => string ‘SMTP Error: Could not connect to SMTP host.’ (length=43)
    ‘data_not_accepted’ => string ‘SMTP Error: data not accepted.’ (length=30)
    ’empty_message’ => string ‘Message body empty’ (length=18)
    ‘encoding’ => string ‘Unknown encoding: ‘ (length=18)
    ‘execute’ => string ‘Could not execute: ‘ (length=19)
    ‘file_access’ => string ‘Could not access file: ‘ (length=23)
    ‘file_open’ => string ‘File Error: Could not open file: ‘ (length=33)
    ‘from_failed’ => string ‘The following From address failed: ‘ (length=35)
    ‘instantiate’ => string ‘Could not instantiate mail function.’ (length=36)
    ‘invalid_address’ => string ‘Invalid address’ (length=15)
    ‘mailer_not_supported’ => string ‘ mailer is not supported.’ (length=25)
    ‘provide_address’ => string ‘You must provide at least one recipient email address.’ (length=54)
    ‘recipients_failed’ => string ‘SMTP Error: The following recipients failed: ‘ (length=45)
    ‘signing’ => string ‘Signing Error: ‘ (length=15)
    ‘smtp_connect_failed’ => string ‘SMTP connect() failed.’ (length=22)
    ‘smtp_error’ => string ‘SMTP server error: ‘ (length=19)
    ‘variable_set’ => string ‘Cannot set or reset variable: ‘ (length=30)

    this error come what can i do now?
    i can’t understand.
    plz help me guyz.

    • Dan Canetti says:


      Looks as though it’s failed to Authenticate. Try ensuring your Email and Password are entered correctly.

  9. Gabriel Hernández says:

    Thanks! Works!=)

    I will save this great website.

  10. Daniel says:

    Works! Thamks for the manual. Google asks to ‘Enable access for less secure apps’ in Gmail, but for testing purposes I see no problem..

  11. deepika says:

    It shows ‘Test message sent’ but I didn’t get any mail.

  12. CarolineElisa says:

    Thanks for this suggestion, but I can only get it to work if I ‘Enable access for less secure apps’ in Gmail, which Google does not recommend. Any other tips? :)

  13. Marty says:

    Tried this, no luck :( Any other suggestion? Thanks!

  14. Marty says:

    Hi! Thank you for a great article. I’m trying it all out, but still get an error when sending the test email: SMTP -> ERROR: Failed to connect to server: Operation timed out (60). So I did as suggested, added extension=php_openssl.dll. But nothing seems to work :( Anyone have another idea? Thanks!

  15. Jesse Brownstein says:

    After sending the test email, the browser loads infinitely without any indication of success/failure. How can I fix?

  16. jam says:

    Thanks very much for sharing your knowledge

  17. Joker says:

    This suggestion should work, But if you got error saying “Failed to connect to server: Unable to find the socket transport “ssl” ” ,
    Then Please do the following

    1. Edit your php.ini from your installed php folder

    2. Search for extension=php_openssl.dll

    3. The initial will look like this ;extension=php_openssl.dll
    Remove the ‘;’ and it will look like this extension=php_openssl.dll
    If you can’t find the extension=php_openssl.dll, add this line extension=php_openssl.dll.

    4.Then restart your Xampp or LAMP or APACHE server (depends upon which of these you’re using).

  18. Syed says:

    Nice article. Helped me. Works for me. Thanks.

  19. Komalchand says:

    I used your setting for localhost but it din’t works where it works for my test server. so ur suggestion will be helpful for me. Thanks

  20. Easy says:

    sory if my question sounds sily bt which inbox am I to check?. am on a local machine without an internet service. or do I need internet to receive the mail?

  21. Bhargav says:

    I didnt get email. Please help me.

  22. Cristian Nebunu says:

    This is actually really helpfull. I needed to test some custom features and now i know how.

  23. adolf witzeling says:

    Very helpful. Thanks for sharing.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.