doucheng5209 2018-05-22 19:52
浏览 82


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->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->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';
    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.

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



  • ¥15 我需要全国每个城市的最新小区名字等数据。
  • ¥15 开发一个小区生态的小程序
  • ¥15 MddBootstrapInitialize2失败
  • ¥15 LCD Flicker
  • ¥15 Spring MVC项目,访问不到相应的控制器方法
  • ¥15 esp32在micropython环境下使用ssl/tls连接mqtt服务器出现以下报错Connected on发生意外错误: 5无法连接到 MQTT 代理,如何解决?
  • ¥15 关于#genesiscsheel#的问题,如何解决?
  • ¥15 Android aidl for hal
  • ¥15 STM32CubeIDE下载程序报错
  • ¥15 微信好友如何转变为会员系统?(相关搜索:小程序)