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 root@db001.company.local. 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 'dbadmin@company.com'. However, by the nature of Postfix and $myorigin, an unqualified recipient would instead qualify to dbadmin@db001.company.local. 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.


This is not possible.

As documented, postfix appends the value of myorigin to all non-fqdn localparts, anywhere in the mail system, if append_at_myorigin is set.

A solution may be available if every address uses a different localpart; in that case, you can use virtual_alias_maps to translate localparts to a given fully-qualified address.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.