Saturday, 3 February 2018

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

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...