# Sending mail as current user



## obamatronic (Jul 31, 2012)

While logged into the system, I su to root:


```
su -
```

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


```
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?


----------



## dalecosp (Aug 8, 2012)

```
[521] Wed 08.Aug.2012 15:49:10                                                                                                                                                                                                               [admin@server][~/default 1200] env | grep -i mail
MAIL=/var/mail/kadmin
EMAIL=webmaster@yahoo.com
```


----------



## obamatronic (Aug 31, 2012)

dailcosp,

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


----------

