我不小心换了一行:
$timenow = $timenow + 1;
到
//$timenow = $timenow + 1;
所以我做了一个无休止的循环。
为什么我的额外安全性(break
功能)不起作用?
我一直收到邮件。当我在while循环中放置echo "1";
时,它会在100秒后停止。但是当我将phpmailer置于循环中时,while并没有停止。
我的代码:
<?php
$times = 20;
$timenow = 0;
$startTime = time();
$timeout = 100; //timeout in seconds
while($timenow < $times){
if(time() > $startTime + $timeout) {
break;
}
//Create a new PHPMailer instance
$mail = new PHPMailer;
//Set who the message is to be sent from
$mail->setFrom('noreply@offertes-krijgen.nl', 'noreply');
//Set an alternative reply-to address
$mail->addReplyTo('noreply@offertes-krijgen.nl', 'noreply');
//Set who the message is to be sent to
$mail->addAddress($somevar, $somevar2);
//Set the subject line
$mail->Subject = 'subject';
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
//Replace the plain text body with one created manually
$mail->AltBody = 'This is the mail';
//Attach an image file
$mail->addAttachment('');
$mail->AddEmbeddedImage('images/phpmailer_mini.png', 'logo');
//send the message, check for errors
if (!$mail->send()) {
$mailerror = 1;
}
$timenow = $timenow + 1;
}
?>
感谢您的帮助