On Fri, Dec 21, 2012 at 08:07:00PM +0200, Hleb Valoshka wrote:

> I want to change addresses like [email protected] to Name.Surname@domain.
> 
> It looks like job for sender_canonical_maps + masquerading, but it
> doesn't work like I want because masquerading is applied _after_
> canonical mappings.

Yes, you can't easily in a single pass both masquerade subdomains
to a parent domain and apply canonical mappings to map outgoing
internal aliases to primary addresses. With Stock Postfix this
takes two rewrite passes, one to do the masquerading and a second
to do the local-part rewriting.

> I also know about other ways to do that but they looks like dirty hacks:
> 1) reflect all possible [email protected] in canonical maps

This does not easily scale.

> 2) use regexp in canonical maps

This also does not scale when the number of users is large, or
users are in LDAP, ...

> 3) use generic mappings

This provides the necessary 2nd pass, and a valid approach, except
that you don't always want to apply such rewriting to the envelope
recipient. The canonical address may not be the best recipient
for inbound mail where the internal <[email protected]>
be preferred for delivery.


> 4) use masquerading on clients and canonical mappings on gateway

This also works, and is essentially what I used to do at previous
employer. The internal mailhubs did masquerading, and the outbound
gateways canonical rewriting.

> So I decided to patch "cleanup" to reorder masquerading and canonical
> mappings (controlled by variable in main.cf) and now I have simple
> configuration with fast canonical mappings (cdb) which look like
> "login Name.Surname" and masquerade_domains=$mydomain.
> 
> But I still believe that I'm missing something and there is better
> way to this.

You're not missing much. Another option is to apply masquerading
before the content filter, and canonical rewriting after if your
MTA is already doing content_filter (say anti-virus, ...) inspection.

I don't see an immediate downside to configurable ordering of
masquerading vs. canonical mapping, other than having to maintain
the feature. That would be the main concern. The feature may be a
bit too surgical (ad-hoc) to make it a permanent feature of Postfix,
and site-specific patches are a burden to your peers and anyone who
has to support the site after you.

-- 
        Viktor.

Reply via email to