Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

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
share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.