$t_email = explode(", ", $list);
$sentEmails = count($t_email);
updateEmail($sentEmails);
for ($i = 0; $i < (count($t_email)); $i = $i + 1) {
if(sentQueue <= 500) {
if (mail($t_email[$i], $subject, $body, $headers)) {
$err .= "<span class='success'>Message successfully sent to " . $t_email[$i] . "</span><br />";
} else {
$err .= "<span class='fail'>Message failed to be sent to " . $t_email[$i] . "</span><br />";
}
} else {
echo "<span class='fail'>Sent over 500 emails. Please wait until the hour is up.</span>";
}
}
在for循环之后,我有了这个:
$result = mysql_query("SELECT * FROM emailLimit");
while ($row = mysql_fetch_assoc($result)) {
$later = $row['hourLater'];
$sent = $row['sentEmails'];
if ($sent == 500) {
echo "Sent all available emails for this hour.<br/>";
}
else if ($timeNow > $later || $sent == 0) {
mysql_query("UPDATE `emailLimit` SET hourLater = '$hourLater', sentEmails = '0'") or die(mysql_error());
} else {
echo "<h4><span class='header'>$sent/500 emails sent. " . RelativeTime(($later)) . " remain in the hour.</span></h4>";
}
}
sentQueue函数
function sentQueue() {
$q = "select * from emailLimit";
$result = mysql_query($q);
$dbarray = mysql_fetch_array($result);
return $dbarray["sentEmails"];
}
编辑:忘了发帖
function updateEmail($vp) {
$q = "select * from emailLimit";
$result = mysql_query($q);
$dbarray = mysql_fetch_array($result);
$vp = $vp + $dbarray["sentEmails"];
$q = "update emailLimit set sentEmails = '$vp'";
mysql_query($q) or die(mysql_error());
}
当我向我的邮件列表发送电子邮件时,我仍然可以收到超过500封电子邮件。它不会停止。我怎么能这样做它如果它达到500就完全停止发送邮件?或者记录超过500的电子邮件,以便我可以在小时结束后通过电子邮件回复它们? (我的主人限制为每小时500人。)
感谢您的帮助。
答案 0 :(得分:0)
发现我的问题我没有把这个功能称为愚蠢的我。 if(sentQueue() <= 500) {
现在修复。