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’.
Now you need to configure the plugin to use Gmail’s SMTP server to send mail. In the SMTP server field, enter smtp.gmail.com
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. yourusername@gmail.com and your Gmail password.
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.
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.
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?
That is to send… smtp… not to recieve the email on wordpress… POP3
my email is not working
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.
That’s Worked. Thanks.
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
Hi new user registration mail contact us mail are working but woocommerce order mail and all not sending to the customers.
i m mukesh
this is too good
not work so work for me thnq…
Works very good! Thank you
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.
Thanks,
From your Google account:
[Settings -> Accounts and Import -> Other Google Account settings -> Sign-in & security -> Connected apps & sites -> Allow less secure apps (turn ON)]
Same here. Otherwise gmail would authenticate because of the “Less secured application”
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.
Just what I needed to do my testing.
I worked well after I enable access to less secure apps in my gmail account. Thanks
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.
Thanks! Works!=)
I will save this great website.
Works! Thamks for the manual. Google asks to ‘Enable access for less secure apps’ in Gmail, but for testing purposes I see no problem..
It shows ‘Test message sent’ but I didn’t get any mail.
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?
Tried this, no luck
Any other suggestion? Thanks!
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!
After sending the test email, the browser loads infinitely without any indication of success/failure. How can I fix?
Thanks very much for sharing your knowledge
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).
Nice article. Helped me. Works for me. Thanks.
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
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?
yes you will need an internet connection to receive email.
I didnt get email. Please help me.
Make sure that you have correctly entered Gmail SMTP settings.
This is actually really helpfull. I needed to test some custom features and now i know how.
Very helpful. Thanks for sharing.