Tim,

> We are going to cut over from one quarantine method to another, so for
> a little while, I need to simultaneously quarantine spam in two different
> ways.
> 
> Right now, I'm forwarding all spam to a single mailbox via smtp.
> 
> I need to add sql quarantine as well.
> 
> I've got the sql quarantining working in the main configuration, so I was
> thinking about using a before_send custom hook to add in the SMTP-based
> quarantine (so it's easy to remove later, when we've completed our upgrade).  
> 
> Would before_send be the best place to do this?

Yes, before_send should be fine.

> Would something like this work?
> 
> sub before_send {
>   my($self,$conn,$msginfo) = @_;
>   if ($msginfo->quarantined_to) {
>       my($quar_addr) = 'quarant...@mydomain.com';
>       Amavis::do_quarantine($conn, $msginfo, undef,
>                             [$quar_addr],
>                             'smtp:[127.0.0.1]:10025:email');
>   }
> }

The do_quarantine now in 2.7.0 has one parameter less,
the $conn is gone now, being redundant.

sub do_quarantine($$$$;@) {
  my($msginfo, $hdr_edits_inherited, $recips_ref,
     $quarantine_method, @snmp_id) = @_;

> Or do I need to call it separately for each recipient, in a loop like this:

You probably need only one copy in quarantine even with
multi-recipient mail, so the loop isn't desired.

> if ($r->SOMETHING) {  # can I check to see if it was quarantined
>                       # for a specific user?

Not really, the quarantined_to() is a property of a message
as a whole. You may test $r->recip_mbxname for indicating a
quarantine location (as opposed to the original recipient address),
but that is probably an unnecessary complication.

> Sorry to reply to my own email...but I've been working on this, and I
> think I have something that should work...but I'm getting an error in
> amavisd-new
> 
> I'm hacking around on amavisd-new 2.7.0pre9.
> 
> I've got a before send hook like this:
> 
> sub before_send {
>   my($self,$conn,$msginfo) = @_;
>   do_log(2,"CUSTOM: before_send hook for additional quarantine");
> 
>    if ($msginfo->quarantined_to) {
>                 my($quar_addr) = 'quarant...@mydomain.com';
>                 Amavis::do_quarantine($conn, $msginfo, undef,
>                               [$quar_addr],
> 'smtp:[127.0.0.1]:10025:email'); }
> }
> 
> But when I run amavisd-new in debug mode, I'm seeing this error:
> 
> (!)custom before_send error: Can't locate object method "sender" via
> package "Amavis::In::Connection" at
> /usr/local/mroute/sbin/amavisd.mroute.2.7.0pre9 line 13713, <GEN17>
> line 54.
> 
> What am I missing?
> Is my lack of perl experience tripping me up? Am I
> not passing the connection or the msginfo properly?

Please leave out the $conn argument in a call to do_quarantine.

Sorry for the incompatibility (there was a compatibility measure
in 2.7.0 up till pre7, but I dropped it in pre8 - I guess I should
put it back).

> And do I need to check quarantined_to for each recipient in some sort
> of loop over msgingo->per_recip_data?

No.

  Mark

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
AMaViS-user mailing list
AMaViS-user@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/amavis-user 
 Please visit http://www.ijs.si/software/amavisd/ regularly
 For administrativa requests please send email to rainer at openantivirus dot 
org

Reply via email to