Showing posts with label Postfix - Change Sender's email address from root. Show all posts
Showing posts with label Postfix - Change Sender's email address from root. Show all posts

Monday, June 2, 2014

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"