phpmailer超时不工作

phpmailer超时不工作,php,phpmailer,Php,Phpmailer,我使用phpmailer发送邮件,我希望得到结果,因为发送邮件非常频繁。所以我想使用phpmailer“timeout”,但它不起作用。 我的代码 $mail=new PHPMailer(); $mail->IsSMTP(); $mail->Timeout=10; $mail->SMTPAuth=true; $mail->SMTPKeepAlive=true; $mail->SMTPSecure=“ssl”; $mail->Host=“smtp.gmail.com”; $mail->Port=4

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

$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=“这就是主题”;
$mail->AltBody=“测试”;
//$mail->WordWrap=50;//设置换行符
$mail->MsgHTML(“test233”);
//$mail->AddReplyTo(“qinqin1920@gmail.com");
$mail->AddAddress(“xxxx@qq.com");
$mail->IsHTML(true);
echo“
”.time().“
”; echo“超时为”。$mail->超时。“
”; 如果(!$mail->Send()){ 回显“邮件错误:”.$mail->ErrorInfo; }否则{ 回显“消息已被发送”; } echo“
”.time().“
”;
echo是: 138381520超时为10消息已发送138381534

您能否帮助我

说明“var$Timeout=10以秒为单位设置SMTP服务器超时”和“此函数在win32版本下不起作用”

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

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

<?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.
?>

“和echo is:138381520超时is 10消息已被138381534”-有什么帮助?好像它在做它的工作。也许时间格式不是你所期望的。您实际期望的是什么?注意:在较新版本的PHPMailer中,默认超时为300秒=5分钟。我还有一个2014年的版本,默认超时时间为10分钟。花了一段时间才找到。。。
<?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.
?>