Hi all,

Is there any way to use the postfix policy delegation mechanism to filter the transport:destination differently for individual recipients in a multi-recipient message?

This is actually a follow-up to my post of 3 days ago: "Can check_policy_service override sender_dependent_relayhost_maps". Events have now moved on...

I have a postfwd.cf rule that is intended to reroute any outbound emails larger than 9MB from authorised clients so that the email is sent out directly to the recipient(s) MX instead of the default which is to relay via Amazon SES - which bounces emails larger than 10MB.

This is the rule:

id=RULE-SIZE-RELAY ; protocol_state==END-OF-MESSAGE ; size>9000000 ; sasl_username=~/^\S+$/ ; recipient_domain!~((local1.com|local2.com|local3.com ...... )); action=FILTER smtp:

The recipient_domain test is necessary because otherwise postfix sends the mail for local users to the external MX - which is itself, so you get "status=bounced (mail for local1.com loops back to myself". So this test ensures that the rule only applies to external addresses.

I didn't realise at the time that the recipient_domain test is meaningless in a 
multi-recipient message.

This works beautifully as long as the message does not:  A) have multiple 
recipients, and B) some of which are local and some external.

It seems that postfwd/postfix does not apply the rule separately to each recipient delivery. If it did then local recipients would fail the test and be delivered normally by the local delivery agent and external recipients would pass the test and be delivered by the FILTER smtp:.

Even if the rule were applied at the RCPT state and that the size was available at that point, presumably the FILTER action will apply to the message as a whole, i.e. _all_ the recipients, not just the external ones.

I had thought that if I added a local-only test to the size rule in the RCPT state with a DUNNO return, then this would take care of the locals leaving only the external recipients to be subjected to the EOM state and the FILTER smtp:.

But I fear there is no way to influence the transport of multiple recipients 
separately and individually.

I have carefully checked out the SMTPD_POLICY_README and considered the use of a BEFORE or AFTER queue filter as a FILTER action from postwd to handle the individual routing. I looked at the MILTER README, having written milters many years ago for sendmail from the bat book, and I don't want to go down that road again.

I have researched the newsgroups and came across two that looked promising: "implementing per recipient size limit" and "Need to clarfiy how to implement spamtrap address checking & discard with before-queue filtering". They both touch on this problem and they both received attention from Wietse and Noel, but don't solve it for me.

Jan Kessler was kind enough to reply to me:
>> Is there any way to get postfwd to apply the rule separately and 
individually to each recipient?
> Unfortunately not. Of course you could integrate postfwd at 'RCPT TO' stage 
but then afaik the size attribute does not work reliable

Can anyone help me with this

Thanks,
Chris Robinson

Reply via email to