Nic
Nic

Reputation: 81

PhpMailer: loading a while and then ERR_EMPTY_RESPONSE

I am dealing with something strange.. I am setting phpmailer and if I have an error I get the error normally

echo "Mailer Error: " . $mail->ErrorInfo;

actually if everything is good, the page loads a while and then it stops loading, getting in chrome the error: ERR_EMPTY_RESPONSE (Impossible to load the page because the server didn't load the data)

This is the content

<?php

$mail = new PHPMailer();

// set mailer to use SMTP
$mail->IsSMTP();

$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 645;
$mail->SMTPAuth = true;     // turn on SMTP authentication

$mail->Username = "[email protected]";  // SMTP username
$mail->Password = "my password"; // SMTP password

$email = '[email protected]';
$mail->From = $email;

$mail->AddAddress("[email protected]", "Name");

$mail->WordWrap = 50;
$mail->IsHTML(true);

$mail->Subject = "Subject of the mail";

$mail->Body = "content";
$mail->AltBody = "content";

if(!$mail->Send())
{
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
}

echo "Message has been sent";
?>

of course I have included this files:

require_once('../library/class.phpmailer.php');
require_once('../library/PHPMailerAutoload.php');

Upvotes: 3

Views: 2358

Answers (2)

Rockanet Rock
Rockanet Rock

Reputation: 1

you need to Upload the PHPMailer to 6.5. beacause the php 7.x it's diferent look that the code change a little bit

Upvotes: 0

Synchro
Synchro

Reputation: 37770

Two mistakes - just load the autoloader, that loads the class for you so that's all you need.

You've set Port = 645; I suspect you meant 465.

For gmail you should follow the example from the docs: use Port = 587 and SMTPSecure = 'tls'.

Upvotes: 1

Related Questions