Plesk – Bulk Spam filtering activation for forwarded mailboxes

When you have a shared IP for multiple domains, it’s important to avoid the blacklisting of the IP for spamming.
Outgoing Spam can be controlled with Plesk 12 by enabling Outgoing Mail Limits but an important point is about mail addresses with forwarding to an external mailbox, especially when you have SRS (will be explained in a future post) activated on your server as SRS will rewrite the Return-Path to your own domain and if Spam is forwarded it’s the same thing as if you really send this Spam from your server.

You may have many mailboxes on the server and setting the spam filter could be a hard work to do it manually, here come the Plesk CLI and SQL queries to the PSA database.

This query list mail addresses that have a forward option enabled to an external mailbox (not an internal domain) and where the spam filter is not enabled. Another condition is to filter it this address has or not a mailbox. If there is a mailbox the Spam filter action should be “Move to the spam folder” if not the Spam should be deleted. This first query extract the mail addresses without mailbox and show the CLI command to enable Spam filtering with the specific action.

Result is

mailbox postbox spamfilter command false false /opt/psa/bin/spamassassin -u -status true -action del

And you just have to past this to a elevated privilege shell on your Plesk server to enable Spam filter to this mail address

Now here is the same SQL query but with the action of moving the Spam to the Spam folder for mail addresses that have a mailbox.

If you let your users change their Spam filter settings, you may have to check multiples time if they didn’t deactivate it.

There is a third action to the Spam filter that add a prefix on the mail subject. For forwarded addresses to external this action should be removed as there is still Spam outgoing from your mail server. Here is the query that identify mail addresses with a forward and the action to tag the mail subject. The command change the action to “Delete”.

And that’s all for this post !

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.