Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this script which runs as root, and when it fails to do something it needs to send a mail using postfix (actually the regular mail command on Centos5).

The problem is that the "from" user in the email is "root", how can I change it to another user?

share|improve this question
up vote 1 down vote accepted

Since you're using postfix, use the postfix sendmail drop-in:

echo "this is the mail" | sendmail -F "Bogus User" -f recipient@destination.address
share|improve this answer

You can always create a new user on the system, and run the "mail" command using that user:

 su foo -c "echo blabla | mail foo@bar"
share|improve this answer
This is crazy and stupid. But then again, you are answering yourself, which means you probably are crazy. It might work. – elcuco Mar 11 '10 at 14:03
Not only is the syntax and flag for su wrong, this is a terrible idea (from a security perspective, at least). – quadruplebucky Mar 11 '10 at 14:28
Now it's "only" a terrible idea. From every point of view ;-) – elcuco Mar 11 '10 at 14:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.