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/main.cf 
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 :
root@domain.com linuxamination@gmail.com
user1@domain.com linuxamination@gmail.com
You can define different mail addresses for each user of Linux. 
Now Run following commands in terminal.
postmap /etc/postfix/generic
and
service postfix restart
Now it displays linuxamination@gmail.com as sender, when I send mail as a root or user1.
echo "content-of-the-mail" | mail -s "subject-of-the-mail" "recipient@mail-address.com" 

2 comments:

  1. Inbox still shows it as root.
    from: root[linuxamination@gmail.com]

    ReplyDelete
  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 ' "recipient@mail-address.com"
    2) or change the full name of user using
    chfn -f "firstname lastname" username

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...