Disable mail service before making any further changes.
Code Block title Disable mail service
# svcadm disable postfix
Edit /etc/postfix/main.cf and add this setting: sender_canonical_maps = regexp:/etc/postfix/sender_canonical so that the before and after look like the following. Notice change on line 26.
Code Block title Change to /etc/postfix/main.cf
+++ Before +++ ... 20 # 21 # Maps and Aliases 22 # 23 alias_database = dbm:/etc/postfix/aliases 24 local_recipient_maps = unix:passwd.byname $alias_maps 25 alias_maps = dbm:/etc/postfix/aliases 26 27 # Debug level ... +++ After +++ ... 20 # 21 # Maps and Aliases 22 # 23 alias_database = dbm:/etc/postfix/aliases 24 local_recipient_maps = unix:passwd.byname $alias_maps 25 alias_maps = dbm:/etc/postfix/aliases 26 sender_canonical_maps = regexp:/etc/postfix/sender_canonical 27 28 # Debug level ...
Now we create a mapping using a regular expression with the following command. However, replace in this example email@example.com with an appropriate email address specific to your environment. This mapping effectively matches an email address that the machine generates based on its current hostname, which usually won't be internet legal such as firstname.lastname@example.org will rewrite it to email@example.com as in this example.
Code Block title Create address mapping
# echo '/^(.*)@(.*)$/ firstname.lastname@example.org' > /etc/postfix/sender_canonical
Enable mail service again which should instantiate this mapping and all new emails produced on the box will have their FROM: field re-written to match the right side of value in step 3.
Code Block title Enable mail service
# svcadm enable postfix