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.

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

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格