[英]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.