我使用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/>";
Run Code Online (Sandbox Code Playgroud)
和echo是:1383181520超时是10消息已经是1383181534
你能帮助我吗
该文档指出"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.
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17305 次 |
| 最近记录: |