Skip to content

Commit

Permalink
Bouncemgt - allowing processing only existing bounces + a related new…
Browse files Browse the repository at this point in the history
… rule action (#1028)

* Update bouncemgt.php

Added &justexisting=true

* Update processbounces.php

1. Added support for &justexisting=true
1. Added support for new bounce rule action

* Update lib.php

Added support for new bounce action

* Update bouncemgt.php

Added non default title (otherwise it takes the wrong one)

* Update processbounces.php

1. Replaced goto with if-else
1. Hardcoded "-1" instead of supplying it in a sprintf value

* Hardcoding defaults for older PHP versions

* Removed modern solution
  • Loading branch information
lwcorp authored Mar 28, 2024
1 parent a9ea8d7 commit 3022f16
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
2 changes: 2 additions & 0 deletions public_html/lists/admin/bouncemgt.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
echo $spb.PageLink2('checkbouncerules', s('Check Current Bounce Rules')).$spe;

echo $spb.PageLink2('processbounces', s('Process Bounces')).$spe;
echo $spb.PageLink2('processbounces&justexisting=true', s('Reprocess Only Existing Bounces'), '', false, s('Reprocess Only Existing Bounces')).$spe;

echo '</ul><br />';

Expand All @@ -24,3 +25,4 @@
echo '<p class="information text-warning"><big>'.s('You have already defined bounce rules in your system. Be careful with generating new ones, because these may interfere with the ones that exist.').'</big></p>';
}
echo '<br /><p class="button">'.PageLink2('generatebouncerules', s('Generate Bounce Rules')).'</p>';

1 change: 1 addition & 0 deletions public_html/lists/admin/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
'unconfirmuseranddeletebounce' => $GLOBALS['I18N']->get('unconfirm subscriber and delete bounce'),
'blacklistuseranddeletebounce' => $GLOBALS['I18N']->get('blacklist subscriber and delete bounce'),
'blacklistemailanddeletebounce' => $GLOBALS['I18N']->get('blacklist email address and delete bounce'),
'decreasecountconfirmuseranddeletebounce' => $GLOBALS['I18N']->get('decrease count and confirm subscriber and delete bounce'),
'deletebounce' => $GLOBALS['I18N']->get('delete bounce'),
);

Expand Down
49 changes: 33 additions & 16 deletions public_html/lists/admin/processbounces.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,26 +505,27 @@ function processMessages($link, $max)
flushBrowser();

$download_report = '';
switch ($bounce_protocol) {
case 'pop':
$download_report = processPop($bounce_mailbox_host, $bounce_mailbox_user, $bounce_mailbox_password);
break;
case 'mbox':
$download_report = processMbox($bounce_mailbox);
break;
default:
Error($GLOBALS['I18N']->get('bounce_protocol not supported'));
if (!isset($_GET['justexisting'])) {
switch ($bounce_protocol) {
case 'pop':
$download_report = processPop($bounce_mailbox_host, $bounce_mailbox_user, $bounce_mailbox_password);
break;
case 'mbox':
$download_report = processMbox($bounce_mailbox);
break;
default:
Error($GLOBALS['I18N']->get('bounce_protocol not supported'));

return;
}
return;
}

if ($GLOBALS['commandline'] && $download_report === false) {
cl_output(s('Download failed, exiting'));
if ($GLOBALS['commandline'] && $download_report === false) {
cl_output(s('Download failed, exiting'));

return;
}
return;
}
// now we have filled database with all available bounces

}
//# reprocess the unidentified ones, as the bounce detection has improved, so it might catch more

cl_output('reprocessing');
Expand Down Expand Up @@ -648,6 +649,22 @@ function processMessages($link, $max)
}
deleteBounce($row['bounce']);
break;
case 'decreasecountconfirmuseranddeletebounce':
Sql_Query(sprintf('update %s set bouncecount = bouncecount -1 where id = %d',
$GLOBALS['tables']['user'], $row['user']));
if (!$confirmed) {
logEvent('User ' . $userdata['email'] . ' confirmed by bounce rule ' . PageLink2('bouncerule&amp;id=' . $rule['id'],
$rule['id']));
Sql_Query(sprintf('update %s set confirmed = 1 where id = %d', $GLOBALS['tables']['user'],
$row['user']));
$advanced_report .= 'User ' . $userdata['email'] . ' made confirmed by bounce rule ' . $rule['id'] . PHP_EOL;
$advanced_report .= 'User: ' . $report_linkroot . '/?page=user&amp;id=' . $userdata['id'] . PHP_EOL;
$advanced_report .= 'Rule: ' . $report_linkroot . '/?page=bouncerule&amp;id=' . $rule['id'] . PHP_EOL;
addUserHistory($userdata['email'], s('Auto confirmed'),
s('Subscriber auto confirmed for') . ' ' . $GLOBALS['I18N']->get('bounce rule') . ' ' . $rule['id']);
}
deleteBounce($row['bounce']);
break;
case 'blacklistuser':
if (!$blacklisted) {
logEvent('User ' . $userdata['email'] . ' blacklisted by bounce rule ' . PageLink2('bouncerule&amp;id=' . $rule['id'],
Expand Down

0 comments on commit 3022f16

Please sign in to comment.