I'm asking a little advice.

On most of my hosts mail is generated for root and then canonicaled to
root@fqdn and is relayed to the MSA on another host.  This is by
design.

  relayhost = msa-fqdn

There is an alias on the originating host for root but it doesn't seem
to expand there.  If that could be fixed, then the rest doesn't matter.

Instead it is relayed to $relayhost (the MSA).

At the MSA it is relayed to the MDA covering mydomain.tld .

  relay_domains = hash:/etc/postfix/transport

  transport:
    mydomain.tld                 mda1.some-subdomain.mydomain.tld
    ...
    otherdomain.tld              mdaN.some-subdomain.mydomain.tld

At the MDA I use cyrus imapd, therefore have:

  local_transport = lmtp:unix:/var/imap/socket/lmtp

There are two problems here.  One is that the alias isn't expanded on
local delivery otherwise it would go to
ad...@somewhere-else.mydomain.tld .  Since local_transport is set,
local(8) is never run.

The second problem is that I have to list every hostname in
the mydestination hash.

  mydestination = hash:/etc/postfix/my-domains

parent_domain_matches_subdomains doesn't apply to mydestination
otherwise I could have a short file that very rarely changed:

  my-domains:
    mydomain.tld                 exists
    subdomain1.mydomain.tld      exists
    subdomain2.mydomain.tld      exists
    .subdomain1.mydomain.tld     exists
    .subdomain2.mydomain.tld     exists

Instead I need a long file that changes now and then:

  my-domains:
    mydomain.tld                   exists
    subdomain1.mydomain.tld        exists
    subdomain2.mydomain.tld        exists
    host1.subdomain1.mydomain.tld  exists
    host2.subdomain1.mydomain.tld  exists
    ...
    host1.subdomain2.mydomain.tld  exists
    host2.subdomain2.mydomain.tld  exists
    ...

This also means the this mail is delivered to root at the MDA and not
to the alias ad...@somewhere-else.mydomain.tld .

It seems that a partial solution at the MDA for sending to
ad...@somewhere-else.mydomain.tld is to use virtual_alias_maps .  This
is a partial solution because it would still require an entry for
every hostname.  Perhaps a complete solution at the MDA is to use
virtual_alias_maps with pcre: or regexp:

  virtual_alias_maps = pcre:/etc/postfix/pcre-alias

  pcre-alias:
    /(root|postmaster|...)@(.*\.)?mydomain\.tld/
        ad...@somewhere-else.mydomain.tld
    /(manager|info|marketing|sales|support)@(.*\.)?mydomain\.tld/
        s...@somewhere-else.mydomain.tld

This is nice because there are less MDA than hosts.  Domains with just
web content and email don't have mail to root@ per se but the outside
world might send to hostmaster or webmaster or the other things that
get aliased to root but there is only one such address per domain.

Perhaps better is to solve this on the sending end.

  virtual_alias_maps = hash:virtual-alias

  virtual-alias:
    root                      ad...@somewhere-else.mydomain.tld
    postmaster                root
    ...

For internally sourced mail solving this at the source might be
cleaner (if virtual_alias_maps is run before relayhost relaying) but
means changing more hosts.  For externally sourced mail this has to be
solved at the MDA but need not use pcre.

It seems to me that there should be a way to enable
parent_domain_matches_subdomains on virtual_alias_maps .
That would save having to resort to using pcre in this case.

Any faults in my thinking on this?

Curtis

Reply via email to