【问题标题】:PHPMailer does not execute code after $mail = new PHPMailerPHPMailer 在 $mail = new PHPMailer 之后不执行代码
【发布时间】:2022-01-10 02:26:34
【问题描述】:

我在本地主机上创建了一个网站。一切准备就绪后,我托管了该网站。但是,现在 PHPMailer 似乎造成了麻烦。邮件没有发送,似乎 PHP 代码在$mail = new PHPMailer 命令之后没有执行。以下是部分代码:

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 = 'mygmail@gmail.com'; // your email id
  $mail->Password = 'mypassword'; // your password
  $mail->SMTPSecure = 'tls';                  
  $mail->Port = 587;     //587 is used for Outgoing Mail (SMTP) Server.
  $mail->setFrom('mygmail@gmail.com', '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;
    }

有人知道解决办法吗?谢谢!

【问题讨论】:

  • 你的 PHP 抛出了什么错误?
  • 也请分享您的错误。
  • 刷新页面后出现空白屏幕。我添加了一些我在网上和控制台中找到的代码,我得到以下信息:POSThttps://www.ziptie.rs/checkout.php 和 ERROR 500 但没有别的
  • 如果您使用的是非常旧且不受支持的 PHPMailer 版本,这将无济于事。
  • 似乎您没有将 PHPMailer 代码文件正确地包含到您的脚本中。升级到最新版本并按照 PHPMailer 主页上的说明进行操作

标签: php web phpmailer


【解决方案1】:

找到升级到 PHPMailer 6.3 的解决方案

【讨论】:

    猜你喜欢
    • 2022-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 2015-02-14
    • 1970-01-01
    相关资源
    最近更新 更多