PHPMailer does not execute code after $mail = new PHPMailer

I have made a website on my localhost. After everything was ready to go I hosted the website. However, now PHPMailer seems to cause the trouble. Mails are not sending and it seems like PHP code does not execute after $mail = new PHPMailer command. Here is part of the code:

if($conn->query($sql)){

  require_once '/home/ziptie/public_html/PHPMailerAutoload.php';
  

  $mail = new PHPMailer;
$mail->SMTPDebug = true;
  $mail->isSMTP();                            // Set mailer to use SMTP 
  $mail->Host = 'smtp.gmail.com';              // Specify main and backup SMTP servers
  $mail->SMTPAuth = true;                    // Enable SMTP authentication
  $mail->Username = '[email protected]'; // your email id
  $mail->Password = 'mypassword'; // your password
  $mail->SMTPSecure = 'tls';                  
  $mail->Port = 587;     //587 is used for Outgoing Mail (SMTP) Server.
  $mail->setFrom('[email protected]', 'ZIPTIE');
  $mail->addAddress($email);   // Add a recipient
  $mail->isHTML(true);  // Set email format to HTML

  $v="http://ziptie.rs/verification-page.php?sifra=$token";
  $body = file_get_contents('/home/ziptie/public_html/verificationemail.html');
  $body = str_replace('promenljiva', $v, $body);
  $mail->Subject = 'Verifikacija kupca, ZIPTIE';
  $mail->Body    = $body;
  $mail->addAttachment("naruzbine ".date("d-m-Y").".zip");
  $mail->send();
  header("Refresh:0; url=https://www.ziptie.rs/verification-page.php");
  //echo '<script>alert("Verifikacioni link je poslat, proverite Vašu mejl adresu.")</script>';
    /*if(!$mail->send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
    } else {
      echo 'Message has been sent.';
    }*/
    }
 else{
      echo $conn->error;
    }

Does anybody know the solution? Thanks!

Upvotes: 0

Views: 135

Answers (1)

found solution in upgrading to PHPMailer 6.3

Upvotes: 1

Related Questions