# how to change from address using shell mail command?



## chrcol (May 20, 2010)

Hi

I am trying to do what I thought would be a very simple thing and that is send mail using the mail command but not have it come from user@server.hostname but able to set the from address.  The reason is nagios emails.

Seems the tricks I have found do not work on the freebsd mail binary.

my mail smtp daemon is exim.

exim itself supports -f sender but it doesnt allow me to set the subject on the command line, so I need to be able to specify the subject and from address on the command, thanks.


----------



## OH (May 20, 2010)

If you know how to add a subject with the mail command, you can use the exim rewrite configuration to have it adjust the sender address.


----------



## chrcol (May 24, 2010)

yep I seen that page, isnt clear enough tho   I couldnt get it to work, you have an example line I could use?

eg. to change

root@server.com to me@domain.com


----------



## chrcol (May 24, 2010)

ok I found a site which gives examples and I seem to have it working now, worked from mail on shell


----------



## ltning (Nov 11, 2013)

Would you mind much sharing the solution?


----------



## chrcol (Dec 1, 2013)

*S*ure.

*I*n exim.conf add a rewrite section like this.

```
begin rewrite

nagios@originaldomain.com "Nagios psuedo-user <nagios@domainyouwant.com>" Ffrsbc
```
*A*lso the user who is sending the email, in my case the nagios user has to be a trusted user in the exim config.


----------

