Postfix - Change Sender's email address from root

When you send mail using Postfix through command line or similar way, it shows sender's e-mail address root@domain-name. You do not want this and you want your defined email should be visible in recipient's mailbox. Follow the steps.

Add following line in the file /etc/postfix/ 
smtp_generic_maps = hash:/etc/postfix/generic
Now edit the file /etc/postfix/generic, if it is not there, create it.
Add your 'from address' and 'the address you want to be seen in place of from address' in this file.
Example :
You can define different mail addresses for each user of Linux. 
Now Run following commands in terminal.
postmap /etc/postfix/generic
service postfix restart
Now it displays as sender, when I send mail as a root or user1.
echo "content-of-the-mail" | mail -s "subject-of-the-mail" "" 


  1. Inbox still shows it as root.
    from: root[]

  2. To change the firstname in mail, you need to follow one of these methods.
    1) Either send mail with -r tag
    echo "content-of-the-mail" | mail -s "subject-of-the-mail" -r 'First Last ' ""
    2) or change the full name of user using
    chfn -f "firstname lastname" username


Related Posts Plugin for WordPress, Blogger...