i'm trying to use php mailer with symfony 2
public function sendMailAction($email){
$user = $this->getUser();
$UserMail = $user->getEmail();
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = 'myGmail@gmail.com';
$mail->Password = '********';
$mail->setFrom('myGmail@gmail.com', 'Mailer');
$mail->addAddress($email, 'A Name');
$mail->isHtml(true);
$mail->Subject = 'PHPmailer test';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
if(!$mail->send()){
return new JsonResponse($mail->ErrorInfo);
} else {
return new JsonResponse("mail envoyé");
}
}
I follow all the github tutorial, try to change port (465 for ssl, and 587 for tsl), and spend a lot of time in stackoverflow to found an awnser, but at final I always have the same mistake "SMTP error : failed to connect to server". Thx