I am having some problems with the mail() function so when I try to send mail with PHPmailer, the below code which I copied from one tutorial is giving me error
<?php
include("PHPMailer-master/class.phpmailer.php");
include('PHPMailer-master/class.smtp.php');
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = "smtp.gmail.com"; // SMTP server
$mail->Username = "[email protected]";
$mail->Password = "SOMEPASS";
$mail->SMTPAuth = true;
$mail->Port = 587;
$mail->SMTPDebug = 2;
$mail->From = "[email protected]";
$mail->AddAddress("[email protected]");
$mail->Subject = "First PHPMailer Message";
$mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
?>
and when i run it i get this error:
2015-05-18 13:46:19 SERVER -> CLIENT: 2015-05-18 13:46:19 SMTP NOTICE: EOF caught while checking if connected 2015-05-18 13:46:19 SMTP Error: Could not authenticate. 2015-05-18 13:46:19 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message was not sent.Mailer error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
from
can't be[email protected]
. It likely has to be[email protected]
. Gmail doesn't let you send from other addresses.$mail->SMTPSecure = 'tls';
and see if it helps.