We have been having some trouble getting Postfix to behave in a very specific fashion in which sender and recipient addresses with only a localpart (i.e. no @domain) are handled differently.
We have a number of applications that use mailx to send messages. We would like to know the username and hostname of the sending party. For example, if root sends an email from db001.company.local, we would like the email to be addressed from
[email protected]. This is accomplished by ensuring $myorigin is set to $myhostname.
We also want unqualified recipients to have a different domain appended. For example, if a message is sent to 'dbadmin' it should qualify to '
[email protected]'. However, by the nature of Postfix and $myorigin, an unqualified recipient would instead qualify to
[email protected]. We do not want to adjust the aliases on all servers to forward appropriately. (in fact, every possible recipient doesn't have an entry in /etc/passwd) All company employees have mailboxes on Exchange, which Postfix eventually routes to, and no local Linux/Unix mailboxes are used or access. We would love to tell our application owners to ensure they use a fully qualified email
address for all recipients, but the powers that be dictate that any negligence must be accommodated.
If we were to keep $myorigin equal to $myhostname, we could resolve this issue by having an entry such as the following in 'recipient_canonical_maps':
@$myorigin @company.com
However, unfortunately, we cannot use variables in these map files. We also want to avoid having to manually enter and maintain the actual hostname in 'recipient_canonical_maps' for each server. Perhaps once our servers are 'puppetized' we can dynamically adjust this file, but we're not there yet.
After an afternoon of fiddling I've decided to reach out. Any thoughts? Thanks in advance.