I am sending email from localhost via gmail using PHP mailer this is my code but the main problem is that when i run the script the doesnot show me any error and i am not receiving any email in gmail id
include("email/class.phpmailer.php");
$mail = new PHPMailer();
$body = "This is just a Test Email";
$mail->IsSMTP();
// enable SMTP authentication
$mail->SMTPAuth = true;
// sets GMAIL as the SMTP server
$mail->Host = "smtp.gmail.com";
// set the SMTP port for the GMAIL server
$mail->Port = 465;
// GMAIL username
$mail->Username = "Mygmail id";
// GMAIL password
$mail->Password = "password";
$mail->From = "Mygmail id";
$mail->FromName = "My Name";
$mail->Subject = "Testing Message";
$mail->AltBody = "To view the message, please use an HTML compatible
email viewer!"; // optional, comment out and test
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
$mail->AddAddress("Receiver Gmail Id");
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
And Please dont make my question as duplicate beacause i tried all other answers but not find any solution