gpt4 book ai didi

phpmailer超时不起作用

转载 作者:行者123 更新时间:2023-12-03 19:58:13 27 4
gpt4 key购买 nike

我使用phpmailer发送邮件,我想得到结果,因为发送邮件非常频繁。所以我想使用 phpmailer“超时”。但它不起作用。
我的代码

        $mail             = new PHPMailer();
$mail->IsSMTP();
$mail->Timeout = 10;
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "qinqin1920@gmail.com";
$mail->Password = "xxxx";
$mail->From = "qinqin1920@gmail.com";
$mail->Subject = "This is the subject";
$mail->AltBody = "test";
//$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML("test233");
//$mail->AddReplyTo("qinqin1920@gmail.com");
$mail->AddAddress("xxxx@qq.com");

$mail->IsHTML(true);

echo "<br/>".time()."<br/>";
echo "time out is ".$mail->Timeout."<br/>";
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been";
}
echo "<br/>".time()."<br/>";

和 echo 是:
1383181520 超时为 10 消息已 1383181534

你能帮助我吗

最佳答案

documentation声明“var $Timeout = 10 以秒为单位设置 SMTP 服务器超时”和“此功能不适用于 win32 版本。”

如果您想要更长的超时值,只需将其设置为一分钟(60 秒)左右。如果您通过同一个 SMTP 服务器发送多封电子邮件,可能对 keep the connection open 有益。 ,但记得在最后关闭它。

如果确实延长了超时时间,还要确保增加 time limit在脚本上,或将其全部删除:

<?php
set_time_limit(0); // remove a time limit if not in safe mode
// OR
set_time_limit(120); // set the time limit to 120 seconds

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Timeout = 60; // set the timeout (seconds)
$mail->SMTPKeepAlive = true; // don't close the connection between messages
// ...
// Send email(s)
$mail->SmtpClose(); // close the connection since it was left open.
?>

关于phpmailer超时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19696720/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com