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?

link|improve this question
feedback

2 Answers

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 bogususer@some.net recipient@destination.address
link|improve this answer
feedback

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"
link|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
feedback

Your Answer

 
or
required, but never shown

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