简体   繁体   English

PHP邮件程序SMTP connect()失败。 (2018年3月1日)

[英]PHP mailer SMTP connect() failed. (03/01/2018)

I got some problem when I try to use PHPMailer code. 当我尝试使用PHPMailer代码时遇到了一些问题。 This code still works on Oct/2017 but not work since Dec/2017 to now. 该代码仍可在2017年10月使用,但自2017年12月至今至今不可用。 I tried to find other similar question but time seems too odd, or it doesn't help. 我试图找到其他类似的问题,但时间似乎太奇怪了,否则没有帮助。 I didn't change any code inside since I finished. 自完成后,我没有更改内部任何代码。 but error appeared when time passed. 但是随着时间的流逝出现了错误。 And I got this error: 我得到了这个错误:

SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

when I try to find it on troubleshotting, it says it might cause by localhost. 当我尝试在疑难解答中找到它时,它说可能是本地主机引起的。 Here is my code: 这是我的代码:

function mailsend($email,$accepter,$title,$content){
  include_once("../lib/PHPMailer/PHPMailerAutoload.php");   
  $mail = new PHPMailer();                        

  $mail->IsSMTP();                                
  $mail->SMTPAuth = true;                         

  $mail->SMTPSecure = "ssl";                      
  $mail->Host = "smtp.gmail.com";                 
  $mail->Port = 465;                              
  $mail->CharSet = "utf-8";                       
  $mail->Encoding = "base64";
  $mail->WordWrap = 50;                           



  $mail->Username = "myaccount@gmail.com";     
  $mail->Password = "mygmail_account_password";              

  $mail->From = "sender@gmail.com";         
  $mail->FromName = "sender_name";                 

  $mail->Subject = $title; 

  $mail->IsHTML(true);    


  $mailList =       
      array(
          array($email,$accepter)            
      );

  foreach ($mailList as $receiver) {
      $mail->AddAddress($receiver[0], $receiver[1]);  

      $mail->Body = $content;
      if($mail->Send()) {                             
        // echo"<script>alert('success_sended');</script>";
      } else {
        echo $mail->ErrorInfo;
        echo "<br>";
      }
      $mail->ClearAddresses();
  }
}

If I want to change some code to make it work again where can I start? 如果我想更改一些代码以使其再次起作用,那么我应该从哪里开始呢? Cheers for taking a look. 欢呼一下。

I had the same Error but with Yandex,try adding the following: 我遇到了相同的错误,但是使用Yandex,请尝试添加以下内容:

$mail->SMTPKeepAlive = true; $ mail-> SMTPKeepAlive = true;
$mail->Mailer = “smtp”; $ mail-> Mailer =“ smtp”; // don't change the quotes! //不要更改引号!

See more here https://stackoverflow.com/a/48010266 在这里查看更多https://stackoverflow.com/a/48010266

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SMTP connect()失败的PHP邮件程序 - SMTP connect() failed PHP mailer SMTP Connect() 失败。 邮件未发送。邮件程序错误:SMTP Connect() 失败 - SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed 无法连接到服务器:连接超时(110)SMTP Connect()失败。 邮件未发送。邮件错误:SMTP Connect()失败 - Failed to connect to server: Connection timed out (110)SMTP Connect() failed. Message was not sent.Mailer error: SMTP Connect() failed PHP Mailer SMTP 错误:无法连接到服务器:(0) 但 SMTP 测试器工作 - PHP Mailer SMTP ERROR: Failed to connect to server: (0) but SMTP tester works 邮件程序错误:SMTP connect() 失败。 https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 在我的代码中 - Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting in my code Mailer错误:SMTP connect()失败? - Mailer Error: SMTP connect() failed? 邮件错误SMTP connect()失败 - Mailer Error SMTP connect() failed PHPMAILER Mailer错误:SMTP connect()失败(无法访问Php.ini) - PHPMAILER Mailer Error: SMTP connect() failed (No Access to Php.ini) 消息SMTP connect()的未捕获异常&#39;PHP mailer Exception&#39;失败 - Uncaught exception 'PHP mailer Exception' with message SMTP connect() failed 在PHP邮件中,SMTP连接失败 - in php mailer the smtp connection is failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM