Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have an Ubuntu server running postfix. It is not the mail server for my domain.

Whenever a cron job runs for root, the output mail is not delivered locally, instead it gets sent to via the main mail server. This is not what I want.

I want mail for root to either be delivered locally or forwarded to

I've tried modifying both ~root/.forward and /etc/aliases (and running newaliases), but nothing helps (I guess these files are only checked when postfix tries to deliver mail locally).

What can I do?

This is /etc/postfix/

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
myhostname =
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination =,, localhost
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only


When sending mail to root, this goes into /var/log/mail.log:

Mar  7 09:39:17 linux1 postfix/pickup[31381]: F3B9C98025E: uid=1000 from=<ct>
Mar  7 09:39:18 linux1 postfix/cleanup[31556]: F3B9C98025E: message-id=<>
Mar  7 09:39:18 linux1 postfix/qmgr[28525]: F3B9C98025E: from=<>, size=283, nrcpt=1 (queue active)
Mar  7 09:39:18 linux1 postfix/smtp[31558]: F3B9C98025E: to=<>, orig_to=<root>,[<IP address omitted>]:25, delay=0.72, delays=0.19/0.02/0.27/0.25, dsn=2.0.0, status=sent (250 Ok: queued as A97F5D8126)
Mar  7 09:39:18 linux1 postfix/qmgr[28525]: F3B9C98025E: removed

The name "ct" is my user name. I generated the above text through this command:

echo test | mail -s test root

The content of /etc/mailname is:

The contents of /etc/aliases is:

postmaster:    root

where is where I would like root's mail to be forwarded to.

The content of /etc/hosts actually surprises me a little: localhost linux1

where "mylinux" is the hostname of a host operating system under which linux1 runs as a virtual machine. I'm not sure how "mylinux" got in there. (But could this really be the reason for my problem?)

share|improve this question
Could you provide us your postfix logs when you send a mail to root ? – Dom Mar 7 '13 at 7:56
I have done so in an edit to the original post. – oz1cz Mar 7 '13 at 8:44
Could you give us your /etc/mailname and /etc/aliases files ? Check if /etc/hosts contains the assigned to – Dom Mar 7 '13 at 13:41
I have added the information to the original post. – oz1cz Mar 7 '13 at 15:05
According to your logs, the mail has been correctly sent out to your isp smtp relay. I'd ask them (isp) to check[<IP address omitted>] logs for any clue (antispam, error, ...) about the problem. – user130370 Mar 7 '13 at 15:16

2 Answers 2

up vote 5 down vote accepted

As ususal, check your logs.

In your case, the postfix daemon think the mail is not for it and send it without using /etc/aliases

First check your /etc/hosts file : it should have your machine name corresponding to : linux1

Check your /etc/mailname too, and it should be consistent.

Check your /etc/aliases to see if root user is sent to another people, and redo the newaliases command.

And it should work !

share|improve this answer
Should that be – Nate Feb 27 at 22:30
You can have any address in, so works well too – Dom Feb 28 at 9:36
I had a similar problem while I only wanted to use a smarthost relay to send mails out: "myhostname" had to be "localhost". Anything else skipped the aliases file. – Alex Nov 4 at 22:16

If mydestination is empty or does not contain $myhostname then the /etc/aliases will be ignored because postfix thinks the email is not a local delivery and will therefore not apply the local aliases. So, leave mydestination at the default (postconf -d mydestination or remove it from and the logs should show the to=<...> as your aliased address.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.