Send a mail to your Gmail From Your Localserver - Xampp

How to send email to your Gmail Account from 'localhost'? - php
Prerequisite

a .  Open php.ini file.
b .  Find - [mail function]
c .  Change SMTP = smtp.gmail.com
d .  Change sendmail_from = yourgmailid@gmail.com.
e .  ' ; ' being commented

Your php.ini file should look like this. Replace yourgmailid@gmail.com.




Your send mail function should look like this
$headers = "Content-Type: text/html; charset=utf-8\n";
$to = "tomailid@gmail.com";
$subject = "Sample Subject";
$message = "Sample Message/ HTML Content";
mail($to,$subject,$message,$headers);

After This
You will get Sign-in Attempt Prevented email to your g-mail account




Access For Less Secure Apps

Turning on Enabling for less secure apps will be the solution to access the gmail account.
You can enable here from this link

 https://www.google.com/settings/security/lesssecureapps






This is it. After turning on secure apps, You can send mail to your gmail account from your local server.


Comments

Popular posts from this blog

Exploring Coorg , Karnataka

Exploring Western Ghats, Karnataka

The Electronic Fuel Injection