Switching on mail to the root user

Hi,

I've just installed FreeBSD 9.0-RELEASE-p3 on a clean system. During the installation I created a new user 'admin' and made him/her a member of the 'wheel' group. After the installation was complete I installed the 'sudo' package and added the 'admin' user to /usr/local/etc/sudoers.
Now, I plan not to login as 'root' a lot anymore. The machine will ultimately be a headless server, so my next task was to make 'root' forward all its mail to the 'admin' and then (in the future) have 'admin' forward its mail to a GMail-account. For now, however, I am logging in by [CMD="ssh"]admin@10.0.1.xx[/CMD] from a different machine on the local network. To enable mail forwarding from the root-user to the admin-user I edited the /etc/mail/aliases and added this line somewhere at the top:
Code:
#
root: admin

How hard could that be, I thought. However, neither mail sent to root, nor mail sent directly to admin arrives. When I do:
[CMD=""]mail[/CMD]
It just says:
Code:
No mail for admin

I checked the FreeBSD HandBook (chapter 29), but from that I gather that things should be working as expected. And the current state is not as expected.
The output from some tests and mailq:
Code:
$ mail root
Subject: test root mail
testje root
.
EOT
$ mail admin
Subject: test admin mail
testje admin
.
EOT
$ mail
No mail for admin
$ sudo mailq
		/var/spool/mqueue (18 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
q8IHEx49001287       12 Tue Sep 18 19:15 <admin@boson.local>
                 (host map: lookup (boson.local): deferred)
					 <root@boson.local>
q8IHFA3Q001292       13 Tue Sep 18 19:15 <admin@boson.local>
                 (host map: lookup (boson.local): deferred)
					 <admin@boson.local>

... 16 more tests with the same results removed ...

Google and this forum turn up several results that are mail/sendmail related but none seem relevant. I have not yet installed any more packages. I've considered installing postfix, but I guess if sendmail isn't working then postfix won't change that.

For those interested /etc/rc.conf:
Code:
$ cat /etc/rc.conf
hostname="boson.local"
ifconfig_em0="DHCP"
ifconfig_em0_ipv6="inet6 accept_rtadv"
sshd_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="NO"
$

And the /var/log/maillog that contains the logging of the tests shown above:
Code:
Sep 18 18:24:17 boson sm-mta[1040]: gethostbyaddr(10.0.1.11) failed: 1
Sep 18 18:24:17 boson sm-mta[1041]: starting daemon (8.14.5): SMTP+queueing@00:30:00
Sep 18 18:24:28 boson sm-msp-queue[1045]: starting daemon (8.14.5): queueing@00:30:00
Sep 18 18:49:10 boson sendmail[1159]: gethostbyaddr(10.0.1.11) failed: 1
Sep 18 19:11:57 boson sendmail[1275]: gethostbyaddr(10.0.1.11) failed: 1
Sep 18 19:13:34 boson sendmail[1277]: gethostbyaddr(10.0.1.11) failed: 1
Sep 18 19:14:59 boson sendmail[1285]: q8IHExqh001285: from=admin, size=46, class=0, nrcpts=1, msgid=<201209181714.q8IHExqh001285@boson.local>, relay=admin@localhost
Sep 18 19:15:10 boson sendmail[1290]: q8IHFAfE001290: from=admin, size=49, class=0, nrcpts=1, msgid=<201209181715.q8IHFAfE001290@boson.local>, relay=admin@localhost
Sep 18 19:15:10 boson sm-mta[1287]: q8IHEx49001287: from=<admin@boson.local>, size=367, class=0, nrcpts=1, msgid=<201209181714.q8IHExqh001285@boson.local>, proto=ESMTP, daemon=Daemon0, relay=localhost [127.0.0.1]
Sep 18 19:15:10 boson sm-mta[1287]: q8IHEx49001287: to=<root@boson.local>, delay=00:00:00, mailer=local, pri=30367, dsn=4.4.3, stat=queued
Sep 18 19:15:10 boson sendmail[1285]: q8IHExqh001285: to=root, ctladdr=admin (1001/1001), delay=00:00:11, xdelay=00:00:11, mailer=relay, pri=30046, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q8IHEx49001287 Message accepted for delivery)
Sep 18 19:15:21 boson sendmail[1293]: gethostbyaddr(10.0.1.11) failed: 1
Sep 18 19:15:21 boson sm-mta[1292]: q8IHFA3Q001292: from=<admin@boson.local>, size=371, class=0, nrcpts=1, msgid=<201209181715.q8IHFAfE001290@boson.local>, proto=ESMTP, daemon=Daemon0, relay=localhost [127.0.0.1]
Sep 18 19:15:21 boson sm-mta[1292]: q8IHFA3Q001292: to=<admin@boson.local>, delay=00:00:00, mailer=local, pri=30371, dsn=4.4.3, stat=queued
Sep 18 19:15:21 boson sendmail[1290]: q8IHFAfE001290: to=admin, ctladdr=admin (1001/1001), delay=00:00:11, xdelay=00:00:11, mailer=relay, pri=30049, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q8IHFA3Q001292 Message accepted for delivery)
Sep 18 19:15:55 boson sendmail[1295]: gethostbyaddr(10.0.1.11) failed: 1
$

And while I'm reading this I notice the last line in the maillog.

Okay, uhm, now answering my own question. I guess I'll just complete this post for completeness. Since I didn't find the answer anywhere else I'll add it here in the hope that it may help others.

The error "gethostbyaddr(xx.xx.xx.xx) failed 1" suggests a DNS-lookup failure. Since I am on a local network and I have no DNS installed the DNS-lookup will fail and sendmail will complain and refuse to deliver the mail to the local user. To resolve this I edited the file /etc/hosts and added:
Code:
10.0.1.11               boson.local boson

Now, mail gets delivered. But on a DHCP network this will not work if the IP-lease expires and the address changes. Some hints on how to tackle that would be nice.

My DHCP-server (Apple Airport Extreme) does not offer a DNS service.
Also any hints on how to forward to an external email-address (gmail) are appreciated.
 
If it would be me I will install /usr/ports/dns/dnsmasq (DNS forwarder and DHCP server) to replace DHCP-server (Apple Airport Extreme)

To be able to forward all email to gmail account change
Code:
root: admin
to
Code:
admin: your_email@gmail.com
in the /etc/mail/aliases then run newaliases(1)
 
Back
Top