Custom hooks - some questions

Oleksii Krykun kryol at bigmir.net
Fri Apr 26 13:49:14 CEST 2013


Hi!

I try to realize custom filter which looks for something in message
attachments metadata.

My task is following:

Is something found in metadata then:

1. Notification is sent to admin
2. If message addressed to local recipient then it passed to MTA
    If message addressed to external recipient then it discarded and custom
NDR is sent to sender.

My amavisd-custom.conf looks like following:

sub checks {  # may be left out if not needed
  my($self,$conn,$msginfo) = @_;
...
# search fo desired metadata. If found then $isfound=1
...
    if ($isfound) {
      for my $r (@{$msginfo->per_recip_data}) {
         my($recip) = $r->recip_addr;
         my($is_local) = $r->recip_is_local;

         if (!$is_local) {
           $r->recip_destiny(D_DISCARD);
           $r->recip_smtp_response('554 5.7.0 Bad metadata was found');
           $r->recip_done(1);
          }
     }
}

I didn't done p.1 yet.
But for p.2 I get:

If message addressed to local recipient - all works fine.
If message If message addressed to external recipient then it bounced
instead discarding and sender gets a standard NDR from MTA (don't need).

If I have mixed recipient all works but in maillog I see something like:

Apr 25 13:44:40 mail-new amavis[8314]: (08314-01) Passed CLEAN
{DiscardedOutbound,RelayedInternal}, MYNETS LOCAL [10.0.0.25]:2578
[10.0.0.25] <user1 at sss.local> -> <user2 at sss.local>, Queue-ID: 979633B4C1A,
Message-ID: <B91DDBD94C3C4B20AC8B260AADED2A9B at SSS.LOCAL>, mail_id:
dx19DjMS9oS0, Hits: 0.18, size: 35376, queued_as: 4F6653B4C35, 3691 ms
Apr 25 13:44:40 mail-new amavis[8314]: (08314-01) Blocked OTHER
{DiscardedOutbound,RelayedInternal}, MYNETS LOCAL [10.0.0.25]:2578
[10.0.0.25] <user1 at sss.local> -> <user3 at ttt.local>, Queue-ID: 979633B4C1A,
Message-ID: <B91DDBD94C3C4B20AC8B260AADED2A9B at SSS.LOCAL>, mail_id:
dx19DjMS9oS0, Hits: 0.18, size: 35376, 3691 ms
Apr 25 13:44:40 mail-new postfix/smtp[8426]: 979633B4C1A:
to=<user2 at sss.local>, relay=127.0.0.1[127.0.0.1]:10024, delay=3.7,
delays=0.04/0.01/0.01/3.7, dsn=2.0.0, status=sent (250 2.0.0 from
MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 4F6653B4C35, 1 REJECT,
and 1 DISCARD)
Apr 25 13:44:40 mail-new postfix/smtp[8426]: 979633B4C1A:
to=<user3 at ttt.local>, relay=127.0.0.1[127.0.0.1]:10024, delay=3.7,
delays=0.04/0.01/0.01/3.7, dsn=2.0.0, status=sent (250 2.0.0 from
MTA(smtp:[127.0.0.1]:10025): 250 2.0.0 Ok: queued as 4F6653B4C35, 1 REJECT,
and 1 DISCARD)

Is it normal?

And another question: is it possible to generate custom NDR in sub checks?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.amavis.org/pipermail/amavis-users/attachments/20130426/9039caf9/attachment.html>


More information about the amavis-users mailing list