Beginner's Guide for WordPress / Start your WordPress Blog in minutes

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

Subscribe to WPBeginner

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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit – a collection of WordPress related products and resources that every professional should have!

Reader Interactions

40 CommentsLeave a Reply

  1. This post is WAY out of date. You now need to set up an API and OAuth on Google. The WP Forms website has full details, but allow 15-20 minutes to do so.

    • The post was last updated in 2014, thank you for letting us know we should look into updating this post :)


      • I have just tried this out and it does still work but you have to set “Allow less secure apps: ON” in your Google account, which is not recommended.

        • Thank you for sharing that this still works and how to get it to work.

  2. I installed the plugin but I cant see the options such as those iin Mailer and also cant view the option of SMTP Host, Port, Authentication, Username, Password, etc. In mailer I haveoptions such as PHP, Google, Maligun, Sendgrid, Other SMTP. If I click on Google, they ask Client ID and Client Secret.

    What to do?

  3. Thanks for the tutorial.

    I have xampp and i tried above. It showed test message sent, though below i saw: 2017-10-20 13:06:18 SMTP Error: Could not connect to SMTP host.
    And i didnt see in my yahoo box.

    Please can you help me make this to work.

    Thank you.

  4. Hi i did the same but i have did not get any email for contact form and product enquiry form think that in localhost mail system does not works or there is an idea means please help me

  5. Hi new user registration mail contact us mail are working but woocommerce order mail and all not sending to the customers. :(

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

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

      • From your Google account:

        [Settings -> Accounts and Import -> Other Google Account settings -> Sign-in & security -> Connected apps & sites -> Allow less secure apps (turn ON)]

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

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

    • Hi,

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

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

  10. 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? :)

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

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

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

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

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

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.