Thursday, July 4, 2019

php - SMTP ERROR: Failed to connect to server: (0) Mail not sent

Im trying to send an email on localhost(wamp) but it gives me the error on top!
I also tried with 'tls' and port 587 but same error
my email is configured to receive insecure connection and Imap option is activated ..
pls help me , I need this for school project




$mailto = $_POST['mail_to'];
$mailSub = $_POST['mail_sub'];
$mailMsg = $_POST['mail_msg'];
require 'PHPMailer-master/PHPMailerAutoload.php';

$mail = new PHPMailer();
$mail ->IsSmtp();
$mail ->SMTPDebug = 2;
$mail ->SMTPAuth = true;
$mail ->SMTPSecure = 'ssl';

$mail ->Host = "smtp.gmail.com";
$mail ->Port = 465; /* or 587;*/
$mail ->IsHTML(true);
$mail ->Username = "xxxxx";
$mail ->Password = "xxxxx";
$mail ->SetFrom("xxxxx");
$mail ->Subject = $mailSub;
$mail ->Body = $mailMsg;
$mail ->AddAddress($mailto);


if(!$mail->Send())
{
echo "Mail Not Sent";
}
else
{
echo "Mail Sent";
}

?>

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...