0

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

<?php
$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";
}

?>
  • What line gives the error? – Jonathan Lam Apr 21 '18 at 18:32
  • ToDo: ping test from the CLI, investigate Gmail SMTP/application passwords (not the same as the usual login password!), verify local firewall (out of scope here), and list all the similar question you already found/tried. (This comes up so often. Personal debugging chats are off-topic. As is "pls help me".) – mario Apr 21 '18 at 18:37
  • it gives: Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array ( ) – Ínes Akez Apr 21 '18 at 21:14

0 Answers0