Send mail from your Gmail Account using php
by Mohan[ Edit ] 2014-07-14 18:44:09
Send mail from your Gmail Account using php
Hai,
You can send mails from your mail id without logging into your gmail account.
First configure the sendmail.ini file in xampp server with the following code.
[sendmail]
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=****@gmail.com // your gmail account username
auth_password=******* // your gmail account Password
force_sender=****@gmail.com // your gmail account username
Then configure php.ini file with the following code.
[mail function]
sendmail_path = ""C:xamppsendmailsendmail.exe" -t"
Restart Xampp server. Then
Use mail function in a php file to send mail
$to = "testemail@gmail.com";
$subject = "Hi!";
$body = "Hi,
How are you?";
if (mail($to, $subject, $body)) {
echo ("Message successfully sent!");
} else {
echo ("Message delivery failed...");
}