ec15 Switching on mail to the root user - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Server & Networking > Web & Network Services

Web & Network Services Discussion related to network/web services such as apache, bind, sendmail, etc.

Reply
 
Thread Tools Display Modes
  #1  
Old September 18th, 2012, 18:49
Mausy5043 Mausy5043 is offline
Junior Member
 
Join Date: Sep 2012
Location: Tilburg, NL
Posts: 10
Thanks: 6
Thanked 0 Times in 0 Posts
Default 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 ssh admin@10.0.1.xx 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:
mail
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.
Reply With Quote
  #2  
Old September 19th, 2012, 07:37
SirDice's Avatar
SirDice SirDice is offline
Moderator
 
Join Date: Nov 2008
Location: Rotterdam, Netherlands
Posts: 13,725
Thanks: 47
Thanked 2,023 Times in 1,862 Posts
Default

You need to run newaliases(1) after modifying /etc/mail/aliases.
__________________
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
Reply With Quote
  #3  
Old September 19th, 2012, 15:54
Mausy5043 Mausy5043 is offline
Junior Member
 
Join Date: Sep 2012
Location: Tilburg, NL
Posts: 10
Thanks: 6
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by SirDice View Post
You need to run newaliases(1) after modifying /etc/mail/aliases.
I forgot to mention that. I did indeed execute that right after changing the aliases file.
Reply With Quote
  #4  
Old September 19th, 2012, 18:40
Beeblebrox's Avatar
Beeblebrox Beeblebrox is offline
Member
 
Join Date: Sep 2010
Posts: 713
Thanks: 39
Thanked 76 Times in 68 Posts
Default

NOT SOMETHING THAT YOU SHOULD BE DOING

Unless for testing purposes. But you already know that...
__________________
branch:head - root on zfs - amd64
BLUES, ELWOOD
ILLINOIS LICENSE : B263-1655-2187
CURRENTLY UNDER SUSPENSION
WARRANTS OUTSTANDING : PARKG. 116
MOVING VIOLATIONS : 56
ARREST DRIVER ... IMPOUND VEHICLE
Reply With Quote
The Following User Says Thank You to Beeblebrox For This Useful Post:
Mausy5043 (September 29th, 2012)
  #5  
Old September 20th, 2012, 02:58
AlexJ AlexJ is offline
Member
 
Join Date: Jul 2010
Posts: 127
Thanks: 9
Thanked 36 Times in 32 Posts
Default

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)
Reply With Quote
The Following User Says Thank You to AlexJ For This Useful Post:
Mausy5043 (September 29th, 2012)
Reply

Tags
clean install, dns, mail, mailq, sendmail

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] Cannot send mail to root? tempel33 Web & Network Services 34 May 17th, 2010 20:10
[Solved] how user@wheel group check the root's mail f5b General 5 March 8th, 2010 08:33
I have this mail in /var/mail/root mfaridi General 2 March 17th, 2009 08:16
[Solved] root mail unicyclist General 7 January 3rd, 2009 16:16
root mail and dbus error mfaridi General 1 December 14th, 2008 15:09


All times are GMT +1. The time now is 06:28.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0