Rewriting e-mail headers (recipients) in Postfix (not header_checks) depending on complex logic

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Rewriting e-mail headers (recipients) in Postfix (not header_checks) depending on complex logic

voronin_k

I have a mail system on Postfix+dovecot+amavisd+spamassassin+clamav. Now there is a task, an easy one, actually, but I still cannot find a solution. I need to change headers in emails according to several rules. For example,

IF (<TO> CONTAINS 'ALIAS_1' AND <TO> CONTAINS 'SOMEONE FROM ALIAS_1')
OR (IF <TO>='ALIAS_1' AND <CC> CONTAINS 'SOMEONE FROM ALIAS_1')
THEN (DELETE 'THIS SOMEONE FROM ALIAS_1' FROM <TO> AND DELIVER TO OTHERS)  

or

IF <FROM>=ANYBODY_FROM_ALIAS_1 AND <TO>=ALIAS_1
THEN DELETE 'ONE_EMAIL_ADDRESS_FROM_ALIAS_1' FROM <TO> AND DELIVER TO OTHERS.

or if such requirements could not be met at least some tool would be nice that can add another TO_header or remove some for some conditions.

For example in EXIM MTA it can be done with exim.filter, smth like:

if FROM contains A then deliver to B,C,D

and so on.

I have lurked through http://www.postfix.org/addon.html

but could not find anything useful there.

Header_checks internal feature of Postfix has limitations that make it useless in my case, IMHO.

Any help would be most appreciated!

 

Reply | Threaded
Open this post in threaded view
|

Re: Rewriting e-mail headers (recipients) in Postfix (not header_checks) depending on complex logic

Noel Jones-2
On 12/18/2019 1:22 PM, [hidden email] wrote:

> I have a mail system on Postfix+dovecot+amavisd+spamassassin+clamav.
> Now there is a task, an easy one, actually, but I still cannot find
> a solution. I need to change headers in emails according to several
> rules. For example,
>
> |IF (<TO> CONTAINS 'ALIAS_1' AND <TO> CONTAINS 'SOMEONE FROM ALIAS_1')|
>
> |OR (IF <TO>='ALIAS_1' AND <CC> CONTAINS 'SOMEONE FROM ALIAS_1')|
>
> |THEN (DELETE 'THIS SOMEONE FROM ALIAS_1' FROM <TO> AND DELIVER TO
> OTHERS) |
>
> or
>
> |IF <FROM>=ANYBODY_FROM_ALIAS_1 AND <TO>=ALIAS_1|
>
> |THEN DELETE 'ONE_EMAIL_ADDRESS_FROM_ALIAS_1' FROM <TO> AND DELIVER
> TO OTHERS.|
>
> or if such requirements could not be met at least some tool would be
> nice that can add another TO_header or remove some for some conditions.
>
> For example in EXIM MTA it can be done with exim.filter, smth like:
>
> |if FROM contains A then deliver to B,C,D|
>
> and so on.
>
> I have lurked through http://www.postfix.org/addon.html
>
> but could not find anything useful there.
>
> Header_checks internal feature of Postfix has limitations that make
> it useless in my case, IMHO.
>
> Any help would be most appreciated!
>


Try milter-regex.




Reply | Threaded
Open this post in threaded view
|

Re: Rewriting e-mail headers (recipients) in Postfix (not header_checks) depending on complex logic

Bill Cole-3
In reply to this post by voronin_k
On 18 Dec 2019, at 14:22, [hidden email] wrote:

> I have a mail system on Postfix+dovecot+amavisd+spamassassin+clamav.
> Now
> there is a task, an easy one, actually, but I still cannot find a
> solution.
> I need to change headers in emails according to several rules. For
> example,
>
> IF (<TO> CONTAINS 'ALIAS_1' AND <TO> CONTAINS 'SOMEONE FROM ALIAS_1')
> OR (IF <TO>='ALIAS_1' AND <CC> CONTAINS 'SOMEONE FROM ALIAS_1')
> THEN (DELETE 'THIS SOMEONE FROM ALIAS_1' FROM <TO> AND DELIVER TO
> OTHERS)
>
> or
>
> IF <FROM>=ANYBODY_FROM_ALIAS_1 AND <TO>=ALIAS_1
> THEN DELETE 'ONE_EMAIL_ADDRESS_FROM_ALIAS_1' FROM <TO> AND DELIVER TO
> OTHERS.
>
> or if such requirements could not be met at least some tool would be
> nice
> that can add another TO_header or remove some for some conditions.

MIMEDefang (www.mimedefang.org) is a Milter which can do anything to a
message that you can implement as a Perl snippet. In addition to
manipulating messages and their routing, it also has hooks for
SpamAssassin and a wide range of AV tools, which are its most common
uses.


--
Bill Cole
[hidden email] or [hidden email]
(AKA @grumpybozo and many *@billmail.scconsult.com addresses)
Not For Hire (currently)