Jeremy, > I'm running amavis 2.5.2 and I've written a custom hook for the > checks() subroutine. My hook is analysing the headers of the message > and the sender/recipient domains and, based on a local policy, I might > need to quarantine a message. However I'm not sure what I'm supposed > to do to make this happen. I've had a look at the example in > amavisd-custom.conf, but its quarantining code seems to be taking a > copy of the message and letting the original continue on its merry > way.
Yes, this is pretty much the same as the base code does it, just calling do_quarantine where appropriate, possibly multiple times. Quarantining is in most respects fully independent from other actions (such as passing/discarding/rejecting/bouncing, and sending notifications). > Is there a simple way to tag the message as banned, and let the > regular behaviour for a banned attachment take over? You could call: $r->add_contents_category(CC_BANNED,0); for each recipient object, and: $msginfo->add_contents_category(CC_BANNED,0); once for the whole message, to add CC_BANNED label to a set of contents categories. This should be pretty much indistinguishable from the baseline code doing the same. > Can I do the same per-recipient if I wanted to? Yes, add_contents_category is a property of each recipient (and also a property of a message as a whole, see 'blocking contents category' in 2.5.0 release notes). > I'm doing something like this: > > sub checks() { > ... > if ($need_to_ban_message) { > $msginfo->add_contents_category(CC_BANNED,0); > for my $r (@{$msginfo->per_recip_data}) { > $r->recip_done(1); > } > } > } > > but I get errors in my like like: > > (!!)TROUBLE in check_mail: delivery-notificaton FAILED: Assert > failed: 0, 1, at ... Don't set recip_done to true, just add_contents_category(). If you do set recip_done, you must also set recip_smtp_response(...), indicating the success status of a delivery that you pretended to have done. > It would seem I have a few other things to set in order to correctly > change the status of the message. Am I on the right track? Looks good. > Can I choose to not quarantine a message in some cases, but send a > notificaton as if I had? Additional notifications can be sent from a custom hook, as indicated in the amavisd-custom.conf example. Turning off quarantinining is trickier - I can't think of an elegant way to do it from a custom hook. I admit it would be useful. > Also, I realise that I'm trying to tag a message as banned, which is > normally associated with an attachment. However, I still want to ban > messages by my policy even when there's no attachment. Am I going to > fall foul of anything by overloading the "banned" status? Should I be > setting a message to "badh" instead? There is no involvement of attachents concept there, all MIME parts are treated equally. If there is only one top-level MIME part, so be it, it still has its content type, file type, and possibly even a suggested name. I think you are using the right approach. Mark ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ AMaViS-user mailing list AMaViS-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amavis-user AMaViS-FAQ:http://www.amavis.org/amavis-faq.php3 AMaViS-HowTos:http://www.amavis.org/howto/