Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

what is the easiest way to change the 'from' and 'to' email address on a CentOS server ( 2.6.18-164.el5) for all root and cron daemon emails? The server uses sendmail, my understanding is the following:

  • is relaying messages to mailhost.localdomain.

  • the hosts file contains the right entry to map both mailhost and mailhost.localdomain to the SMTP server

  • the .forward file enables me to see all the emails sent to 'root' (i.e. the root emails are forwarded to my email address)

  • the 'to' and 'from' addresses in both cases look like 'root@entry-in-hosts', where 'entry-in-hosts' is the FQDN in /etc/hosts that is tied to the server which is trying to send the email.

Essentially what I'd like to achieve is when root sends an email, the email address is something that I define (for argument's sake '').

I have investigated masquarading as an option, whereby I'd modify the file to rebuild, however I'd like to get around this option if possible as I don't have the m4 macro package and I would like to avoid installing this.

share|improve this question

migrated from Nov 18 '11 at 12:23

This question came from our site for professional and enthusiast programmers.

To change the recipient of the cron emails, you can add this line to your crontabs:

The From address however will always be user@hostname, so my guess is masquerading is your only option.

share|improve this answer
It's also possible to add line to crontab. – Janne Pikkarainen Nov 18 '11 at 12:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.