On a regular sending host I have set 'myhostname' (because logical hostname differs from the system-level nee AWS autogenerated hostname), 'myorigin=$myhostname' (Postfix default) and 'relayhost=[1.2.3.4]' but 'mydestination' does NOT include $myhostname. I want the relayhost to be the sole repository of rewrite rules.
When I use the mailx tool on a regular host and compose a message to 'root' both the FROM and TO are written as 'root@$myorigin'. This means that at the relayhost I have to include every known host in the 'mydestination' list so that it will then consult /etc/aliases (or Cononical maps) and change the TO value of 'root | root@domain | root@source_hostname' to 'realaccount@someother_domain'. For a handful of machines this is not a problem. 1. What to do when it's a dynamic set or many hosts? 2. I would like the 'TO' to either remain a naked/incomplete 'root' or at worst 'root@mydomain' when it leaves the source machines, but I can't lose the FROM address being fully qualified as 'root@myhostname.mydomain'. In other words, "don't attempt local delivery ever, and if FROM is incomplete, tack on '@$origin'. What combination of settings permits that? The configuration on the source host needs to be as trivial as possible. 3. At the relayhost should I use 'remote_header_rewrite = mydomain.com' or is that dangerous? Should I instead use 'local_header_rewrite_clients = permit_mynetworks' which will convert incomplete TO addresses (eg. 'root') to 'root@myorigin'? Are the results then fed to the Canonical maps? 4. instead of using /etc/aliases on the relayhost (local delivery is not intended) I should probably use something more efficient like Cononical maps. 5. Should there be no Cononical mapping at the relayhost, it looks like I need to set 'local_recipient_maps =' and 'luser_relay = bounce+$user@localhost' so the relayhost squelches returns and bounces for supposedly local destination. Does that sound correct?