I'm trying to send mail to a specific email id from localhost.
I've read this and this plus some other posts, but that didn't solve my problem.
Right now I've the following configuration:
PHP.ini
[mail function]
; *For Win32 only*.
; http://php.net/smtp
SMTP=smtp.gmail.com
; http://php.net/smtp-port
smtp_port=587
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = mypersonal@gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
SENDMAIL.ini
smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
auth_username=mypersonal@gmail.com
auth_password=my above email password
force_sender=mypersonal@gmail.com
**PHP CODE IS **
$to = "someFriend@gmail.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <mypersonal@gmail.com>' . "\r\n";
$check = mail($to,$subject,$message,$headers);
if($check == true){
echo "successfully mail Sent";
}
else{
echo "Email sending Failed";
}
I get Email sending failed
, is anything wrong with this configuration or code ?
I've also allowed my Gmail to less secure apps
I'm also confused about where to put my own gmail id from where the mails would be sending to others.
Please help ! Thanks