Skip to content

Commit 529db00

Browse files
committed
Revert "[2.1] Mail queue Sending"
This reverts commit c041990.
1 parent a51025b commit 529db00

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Sources/ScheduledTasks.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -811,21 +811,19 @@ function ReduceMailQueue($number = false, $override_limit = false, $force_send =
811811
{
812812
// First, figure out when the next send attempt should happen based on the current priority.
813813
$next_send_time = $email['time_sent'];
814-
if ($email['priority'] >= $priority_offset) {
815-
for ($i = 0; $i < $email['priority']; $i++) {
816-
$next_send_time += 20 * max(0, $email['priority'] - $priority_offset);
817-
}
814+
for ($i = 0; $i < $email['priority']; $i++) {
815+
$next_send_time += 20 * max(0, $email['priority'] - $priority_offset);
818816
}
819817

820818
// If the email is too old, discard it.
821819
if ($next_send_time > $email['time_sent'] + $smtp_expire) {
822820
continue;
823821
}
824822

825-
++$email['priority'];
823+
$email['priority'] = max($priority_offset, $email['priority'], min(ceil((time() - $email['time_sent']) / $smtp_expire * ($max_priority - $priority_offset)) + $priority_offset, $max_priority));
826824

827-
// Don't send if it's too soon.
828-
if (time() < $next_send_time) {
825+
// Don't send if it's too soon. Also, if we've already failed a few times, only send on every fourth attempt so that we don't DOS some poor mail server.
826+
if (time() < $next_send_time || ($email['priority'] >= $priority_offset && $email['priority'] % 4 !== 0)) {
829827
if ($email['priority'] < $max_priority) {
830828
$failed_emails[] = array($email['to'], $email['body'], $email['subject'], $email['headers'], $email['send_html'], $email['time_sent'], $email['private'], $email['priority']);
831829
}

0 commit comments

Comments
 (0)