Sending mail as current user

While logged into the system, I su to root:

Code:
su -

From that point, I am generating an email using the mail command:

Code:
echo "test" | mail -s "testing" person@example.com

Even then I have switched to he root user, the recipient received the email and the From: address shows the non-root user that I logged in as before switching to root.

Is there any way around this?
 
Code:
[521] Wed 08.Aug.2012 15:49:10                                                                                                                                                                                                               [admin@server][~/default 1200] env | grep -i mail
MAIL=/var/mail/kadmin
EMAIL=webmaster@yahoo.com
 
dailcosp,

I assume your solution is if I were writing a script. But what if I am doing it solely from the command line?
 
Back
Top