Changes

From SME Server
Jump to navigationJump to search
5,662 bytes added ,  14:06, 8 April 2019
Created page with "<span id="_top">Qpsmtpd#Plugins</span> = NAME = handler - generic email handler/redirector = DESCRIPTION = Generic plugin to reject, drop, redir..."
<span id="_top">[[Qpsmtpd#Plugins]]</span>
= [[#___top|NAME]] =

handler - generic email handler/redirector

= [[#___top|DESCRIPTION]] =

Generic plugin to reject, drop, redirect, or munge an email based on a numeric score passed as a transaction note e.g. by spam or virus filters. The intention is for this plugin to be able to implement most handling 'policies' in one place, allowing filtering plugins (e.g. spam/virus/etc.) to be simpler, pluggable, and cumulative.

handler should appear in the qpsmtpd config/plugins file after the filter plugins it is assocated with, but before any QUEUE plugins.

Note: redirection requires a recipients() mutator that is not available in stock Qpsmtpd. The one-line patch should be available from wherever you sourced this plugin.

Note: if you want to invoke 'handler' multiple times (e.g. for both spam handling and virus handling), you can create symlinked versions and use the symlink names in the config/plugins file e.g.

<pre> spamhandler note spam_score redirect_threshold 7 redirect_recipient spam
vhandler note virus_score redirect_threshold 1 redirect_recipient virus</pre>
= [[#___top|CONFIG]] =

handler accepts the following parameters either via the config/plugins line or via a 'handler' (or your symlinked name, if applicable) config file (one parameter per line, name and value space-separated).

<dl>
<dt>note &lt;name&gt;
<dd><p>The name of the transaction note containing the numeric score to be used to determine how we handle the mail. Default: spam_score.</p>
<dt>reject_threshold &lt;threshold&gt;[-&lt;max_threshold&gt;]
<dd><p>The score at which the mail will be rejected outright (or a range within which the score must fall if max_threshold is specified). This should probably be pretty large e.g. for spamassassin, 15 or 20. Rejection is a terminal state, so rejected mail is never redirected or munged. Default: never reject.</p>
<dt>reject_note &lt;name&gt;
<dd><p>A transaction note containing the message to be issued with a rejection. The escape sequences %n and %v can be used as placeholders for the score transaction note and its value, respectively. The default message is: &quot;%n too high - message denied.&quot; Default reject_note: none.</p>
<dt>drop_threshold &lt;threshold&gt;[-&lt;max_threshold&gt;]
<dd><p>The score at which the mail will be dropped i.e. accepted, and then fed to /dev/null (or a range within which the score must fall if max_threshold is specified). Dropping the mail is a terminal state, so rejected mail is never redirected or munged. Default: never drop.</p>
<dt>redirect_threshold &lt;threshold&gt;[-&lt;max_threshold&gt;]
<dd><p>The score above which the mail will be redirected instead of delivered to the specified recipients (or a range within which the score must fall if max_threshold is specified). Requires the 'redirect_recipient' parameter below. Default: none.</p>
<dt>redirect_recipient &lt;recipient_addr&gt;
<dd><p>Email address to which mail scoring above the redirect_threshold (or within the reject_threshold range) is redirected (currently requires a one-line patch to Qpsmtpd::Transaction).</p>
<p>If the address is a standard email address it replaces the current recipient list completely. Otherwise, if the redirect address is a bare username with no domain component then existing recipient domains are retained, and the username is munged as follows:</p>
<ul>
<li>if the address is a bare username ending in a hyphen (e.g. 'spam-'), it is prefixed to existing recipient usernames (allowing per-user mailboxes within a spam account and a spam-default catchall)</li>
<li>if the address is a bare username beginning with a hyphen (e.g. '-spam'), it is suffixed to existing recipient usernames (allowing per-user spam mailboxes)</li>
<li>otherwise the bare username (e.g. 'spam' replaces existing recipient usernames (allowing per-domain spam mailboxes)</li></ul>

<p>Examples, spam to recipient gavin@openfusion.com.au:</p>
<pre> redirect_recipient spam@my.domain.com # -&gt; spam@mydomain.com
redirect_recipient spam # -&gt; spam@openfusion.com.au
redirect_recipient spam- # -&gt; spam-gavin@openfusion.com.au
redirect_recipient -spam # -&gt; gavin-spam@openfusion.com.au</pre>
<dt>munge_threshold &lt;threshold&gt;[-&lt;max_threshold&gt;]
<dd><p>The score above which the mail becomes a candidate for munging in various ways (or a range within which the score must fall if max_threshold is specified). See the 'munge_subject' parameter below. Default: do not munge.</p>
<dt>munge_subject &lt;tag&gt;
<dd><p>The tag (default: '***SPAM***') to prepend to the Subject header (if not already present) if the score exceeds munge_threshold above.</p>
<dt>per_recipient &lt;boolean&gt;
<dd><p>(only via config/plugins) Allow per-recipient 'handler' config files to be used. Note that because handler is a post_data plugin, it is required and assumed that all recipients are using the same config definitions (see e.g. the denysoft_multi_rcpt plugin).</p></dl>

= [[#___top|NOTES]] =

Might be other actions that could usefully be included here, such as adding to blacklists or greylists or tarpits (e.g. Spam Cannibal).

Currently only tests transaction notes. Should probably extend this to connection notes to as well, to allow connection plugins to be handled too.

= [[#___top|AUTHOR]] =

Gavin Carr &lt;gavin@openfusion.com.au&gt;.

<!-- Generated Mon Apr 8 09:06:04 EDT 2019 using
perldoc -T -ohtml $plugins/$1 \|pandoc -f html -t mediawiki \|sed '1 i\\n\n\n<span id="_top">[[Qpsmtpd#Plugins]]</span>' \|sed -e 's#</d.>##'
-->
----
[[Category:Qpsmtpd|handler]]

Navigation menu