<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div><div><div><div>Hi!<br><br></div>I try to realize custom filter which looks for something in message attachments metadata.<br><br></div>My task is following:<br>
<br></div>Is something found in metadata then:<br><br></div>1. Notification is sent to admin<br></div>2. If message addressed to local recipient then it passed to MTA<br></div> If message addressed to external recipient then it discarded and custom NDR is sent to sender.<br>
<br></div>My amavisd-custom.conf looks like following:<br><br>sub checks { # may be left out if not needed<br> my($self,$conn,$msginfo) = @_;<br>...<br></div># search fo desired metadata. If found then $isfound=1<br>...<br>
if ($isfound) {<br> for my $r (@{$msginfo->per_recip_data}) {<br> my($recip) = $r->recip_addr; <br> my($is_local) = $r->recip_is_local; <br> <br> if (!$is_local) {<br>
$r->recip_destiny(D_DISCARD);<br> $r->recip_smtp_response('554 5.7.0 Bad metadata was found');<br> $r->recip_done(1);<br> }<br> }<br>}<br><br></div>I didn't done p.1 yet.<br>
</div>But for p.2 I get:<br><br></div>If message addressed to local recipient - all works fine.<br></div>If message If message addressed to external recipient then it bounced instead discarding and sender gets a standard NDR from MTA (don't need).<br>
<br></div>If I have mixed recipient all works but in maillog I see something like:<br><br>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@sss.local> -> <user2@sss.local>, Queue-ID: 979633B4C1A, Message-ID: <B91DDBD94C3C4B20AC8B260AADED2A9B@SSS.LOCAL>, mail_id: dx19DjMS9oS0, Hits: 0.18, size: 35376, queued_as: 4F6653B4C35, 3691 ms<br>
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@sss.local> -> <user3@ttt.local>, Queue-ID: 979633B4C1A, Message-ID: <B91DDBD94C3C4B20AC8B260AADED2A9B@SSS.LOCAL>, mail_id: dx19DjMS9oS0, Hits: 0.18, size: 35376, 3691 ms<br>
Apr 25 13:44:40 mail-new postfix/smtp[8426]: 979633B4C1A: to=<user2@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)<br>
Apr 25 13:44:40 mail-new postfix/smtp[8426]: 979633B4C1A: to=<user3@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)<br>
<br></div>Is it normal? <br><br></div>And another question: is it possible to generate custom NDR in sub checks?<br><div><div><br></div></div></div>