We have an RHEL-6 host on which jobs like cron and logwatch generate emails
to the local root user. No one logs into this host as root to read those
emails; we want to forward them to the managers (like me) who need to see
them. I can get postfix working to send emails to remote users, but I can't
seem to get it to forward root's email.

I initially made the following changes to the freshly-installed postfix config:

# postconf -e myorigin=stanford.edu
# postconf -e 'relayhost=[smtp.stanford.edu]’
# postconf -e local_transport="error:local delivery disabled"
# postconf -e smtp_use_tls=yes

Then I did a "service postfix restart". At this point, the following test
was successful:

# echo "Test message" | mail -s "Test of postfix" l...@stanford.edu

I then edited /etc/aliases and added the alias for the root user:

root:           manag...@sesmail.stanford.edu

Then I ran newaliases. I tried to send a test email to root:

# echo "Test message" | mail -s "Test of postfix" root

This message was never delivered. In /var/log/maillog, we see:

Mar  5 11:04:30 seswsbackup postfix/smtp[22412]: 2959DC0A06: 
to=<r...@stanford.edu>, orig_to=<root>, 
relay=smtp.stanford.edu[171.64.13.8]:25, delay=0.34, delays=0.1/0.02/0.04/0.18, 
dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 6A52721AB3)

That "r...@stanford.edu" would seem to be the problem; postfix has appended
the domain to the user name before trying to do any alias expansion, so of
course the alias doesn't trigger. I gather that this "append the domain first"
behavior is normal for postfix; can I fix things so my alias will work, or is
there another way to redirect or forward root's email?

I've tried many fixes proposed on the web without success.

I reverted /etc/aliases to its original form (no alias for root) and instead
put a .forward file in root's home directory containing just the line
"manag...@sesmail.stanford.edu". That didn't help; mail was still directed to
r...@stanford.edu, which failed.

I tried the line

root    root@localhost

in /etc/postfix/virtual, as suggested in the STANDARD_CONFIGURATION_README, 
then ran "postmap /etc/postfix/virtual"; test email still failed, still using
"r...@stanford.edu" as its destination.

I also tried the line:

root@$myorigin root@$myhostname

in /etc/postfix/virtual, but that also failed.

I tried adding the line:

@stanford.edu   manag...@sesmail.stanford.edu

to /etc/postfix/canonical, then running "postmap /etc/postfix/canonical", but
the destination is still "r...@stanford.edu" and the message is still not
delivered to the managers address.

So, how do I get email for root to go to manag...@sesmail.stanford.edu?

Here's my current main.cf:

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
inet_interfaces = localhost
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
relayhost = [smtp.stanford.edu]
smtp_use_tls = yes
myhostname = seswsbackup.stanford.edu
myorigin = stanford.edu

The end of /etc/aliases:

# Person who should get root's mail
root:           manag...@sesmail.stanford.edu

There is a local user named "root", with a real shell:

root:x:0:0:root:/root:/bin/bash

-- 
Kai Lanz         Stanford University          School of Earth Sciences

Reply via email to