changing cron's From: address in emails

Kelly Martin kellymartin at
Tue Oct 27 18:45:49 UTC 2009

On Sun, Oct 25, 2009 at 11:19 AM, krad <kraduk at> wrote:
>> On Sat, 24 Oct 2009 01:08:21 -0600
>> Kelly Martin <kellymartin at> wrote:
>> > Greetings, here's a simple question for the FreeBSD gurus out there. I
>> > have several servers running cron scripts daily for me, and they all
>> > send me e-mail with their output. Regardless of which server it is,
>> > each of these e-mails have the From: address looking exactly the same.
>> > They all say they are from the "Cron Daemon". Fine, but I'd like to
>> > know more clearly which server the cron output is from.
>> >
>> > How can I change the From: address of these emails to "Myserver Cron
>> > Daemon" instead? I know cron runs as the user, so it's not immediately
>> > obvious to me how to change the From: field. Already the subject line
>> > says something like "Cron <root at Myserver> ..." but this doesn't stand
>> > out enough for my tired eyes.
> The simplist way to do it is get you scripts to print out a to, from and
> subject line at the top of their output containing the information you want.
> eg
> To: your at
> From: scriptname at
> Subject: scriptname, hostname
> other script output
> Then in the cron pipe the output into sendmail with the t flag
> eg
> 1 1 * * * somescript 2>&1 | /usr/sbin/sendmail -t
> you will then get the loverly named emails

That is very cool, thank-you! It works beautifully.

And as a bonus I've learned something new about how to e-mail the
output from my scripts, which can be useful for all sorts of things.


More information about the freebsd-questions mailing list