How to change postfix sender address

postfix

How do I make postfix send emails from user@mydomain instead of root@hostname? Even after installing and entering my domain when it asked, it's still being sent with the hostname and not the domain I provided. In my main.cf file

myorigin = /etc/mailname

and /etc/mailname contains:

gateblogs.com

which is my domain.

I have managed to fix my problem temporarily by changing my hostname to my domain name. However, how can I change who the email is from; currently mail is shown from root I want it to be something else.

Best Answer

Postfix itself does not "set" the from address for an mail (as long has you haven't really tweaked the postfix configuration).
The from address header of an e-mail is set by the mail client which is asking postfix to deliver the mail (Postfix is a MTA).

Hence you are looking at the wrong place - as far as I understand your question.

You mentioned that you are using the mail command to test your configuration. This neat little command is - by default - using the systems user name under which the command gets executed. In your case this seems to be user root. Try executing mail as a different user and you'll see the from part changed.
And since the command mail does - by default - not append the domain part to the "from" header of the mail it hands over to postfix, postfix is appending the myorigin part automatically to root.

Though mail is not limiting you to not use some other "from" e-mail header. You can read about on the www or the manual page of mail. Also consider using sendmail.

Please note that postfix is a beast when it comes to configurability. You may accomplish almost everything you want postfix to do if you really understand its architecture and configuration files.
But since you are asking a quite 'newbee-ish' question you may not yet want to go down that road...

Related Question