dongtazu3080 2018-05-24 20:19 采纳率: 100%
浏览 76
已采纳

新的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 error_log file says :

PHP Warning: stream_select(): unable to select [4]: Interrupted system call (max_fd=5) in /root/vendor/phpmailer/phpmailer/src/SMTP.php on line 1124

I have tried many examples,sometimes the it says connect() failed, sometimes couldn't connect to host and sometimes 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 php 7.

  • 写回答

1条回答 默认 最新

  • duanputian5341 2018-05-25 06:58
    关注

    The important thing here is:

    I am using godaddy

    GoDaddy blocks outbound SMTP; you must use their servers (*.secureserver.net).

    You're also using SMTPSecure = 'tls' with Port = 465, which will not work. Change to SMTPSecure = 'ssl'.

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

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵