Sunday, September 22, 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

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...