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 firstname.lastname@example.org 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 email@example.com will rewrite it to firstname.lastname@example.org as in this example.
Code Block title Create address mapping
# echo '/^(.*)@(.*)$/ email@example.com' > /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