2

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:

  • sendmail.cf 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 'root@example.com').

I have investigated masquarading as an option, whereby I'd modify the sendmail.mc file to rebuild sendmail.cf, 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.

migrated from stackoverflow.com Nov 18 '11 at 12:23

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

4

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

MAILTO=you@example.com

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

  • 3
    It's also possible to add MAILFROM=johndoe@example.com line to crontab. – Janne Pikkarainen Nov 18 '11 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy