Hello!
I have a working Postfix/Dovecot setup with virtual domains and users in a mySQL database.
Problem:
I need to do some rewriting of the sender addresses of outgoing mail according to this general rule/pseudocode:
IF
(user=MYVIRTUALUSER@mydomain.address) AND
(Subject.Field.Contains.The.String = "send.as.barbara")
THEN:
Swap all instances of "From:
MYVIRTUALUSER@mydomain.address" to
"From:
barbara@other.domain.address"
What this is meant to accomplish:
When I use a remote mail client, I can choose sender identity based on the content of the Subject: field.
If no special string is put into Subject:, then the mail is left unchanged (From:
MYVIRTUALUSER@mydomain.address).
If a special string "send.as.x" is put into Subject:, then the filter script changes From: fields, so that Postfix relays the mail to predefined (authenticated) SMTP servers by use of sender_dependent_relayhost_maps.
This makes possible "server side identity management" for the case that I use a really stupid (!) mail client with no identity management of its own, and that can use only 1 SMTP server.
What I've tried so far:
Nothing!
I was thinking I could use 'procmail' to do this, but it seems that it can only act on /incoming/ mail, not outgoing.
The built-in Postfix address rewriting features don't seem to be flexible enough to do rewriting based on a regex in specific fields (or anywhere).
My question:
What can I use to rewrite Sender address according to the rule above? A shell script? How do I make Postfix filter outgoing mail through it?
EDIT:
This page
http://www.debianadmin.com/how-to-ad...n-postfix.html looks close to what I want to do! Seems to use the "dfilt" pipe?