doucheng5209 2018-05-22 19:52
浏览 82
已采纳

新的PHPMailer没有运行?

Below is the phpmailer code which I am using :

    use PHPMailer\PHPMailer\PHPMailer;
    use PHPMailer\PHPMailer\Exception;
    require '../vendor/autoload.php'; 
    $mail = new PHPMailer(true);  
    try { 
     $mail->SMTPDebug = 2; 
     $mail->isSMTP();
     $mail->Host = as given in the configure mail client window; 
     $mail->SMTPAuth = true; 
     $mail->Username =as given in the configure mail client window; 
     $mail->Password = as given in the configure mail client window;  
     $mail->SMTPSecure = 'tls' ;
     $mail->Port = 465; 
     $mail->setFrom('my email', 'my name'); 
     $mail->addAddress('email', 'name');
     $mail->isHTML(true);
     $mail->Subject = 'Here is the subject';
     $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(); 
    echo 'Message has been sent';
     } 

    catch (Exception $e) { 
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
     }

The page keeps loading and the e-mail is not sent,What is happening ? and how should I configure this . I am using godaddy cpanel.

  • 写回答

1条回答 默认 最新

  • douyang5943 2018-05-22 20:15
    关注

    You're using SMTP to localhost (which is the recommended and usually the fastest sending mechanism, as far as your script is concerned), but you've enabled encryption and authentication, so your local mail server will need to present a valid certificate for localhost, which is not going to happen. It's usually unnecessary to use encryption or authentication when sending to localhost, because you can whitelist localhost as the source, and this will make it even faster.

    If you set SMTPDebug = 2, you can look at the timestamps in the SMTP conversation and see which part is taking a long time.

    Keepalive won't help unless you're sending lots of messages in quick succession.

    It may also help to look in your local mail server's logs and see if there's anything interesting in there.

    You're also using a very old version of PHPMailer; get the latest, and base your code on the examples provided.

    You should have no trouble submitting a few hundred messages per second.

    If your problem is that submission is fast, but ultimate delivery is slow, you need to look at your local mail server logs for why that is. You may be getting delivery deferrals.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥55 AD844 howland电流源如何驱动大额负载
  • ¥15 C++ /QT 内存权限的判断函数列举
  • ¥15 深度学习GFnet理解问题
  • ¥15 单细胞小提琴堆叠图代码
  • ¥50 升级strust2版本到2.3.15.1后使用ognl3.0.6.jar windows环境中没有问题,但部署到linux环境报错
  • ¥15 vue页面,node封装接口
  • ¥15 求TMS320F280039C工程模板!
  • ¥15 delphi+fastreport实现分组补空打印问题
  • ¥15 使用python把两台mysql数据库服务器数据导出和导入
  • ¥15 NodeBB论坛配置Apache Solr中文搜索引擎的详细教程