Sending email from localhost with php


A lot of developers set up PHP on their local machine to test server side development. Here's a little trick how to be able to send email from localhost so you can test email without any difficulty.

Note: This only works when sending email to google hosted email addresses.

1. Go to your php.ini file and change SMTP = localhost to SMTP = and uncomment sendmail_from and put in your sending gmail address.

2. Go to cmd and type iisreset

3. In php, test it with mail("[youremail]", "subject", "body");

mail() [function.mail]: SMTP server response: 550-5.7.1 [] The IP you're using to send mail is not authorized to 550-5.7.1 send email directly to our servers. Please use the SMTP relay at your 550-5.7.1 service provider instead. Learn more at 550 5.7.1 xg10si5792766pbc.237

I haven't tried this in years so I don't know if it still works