Sending mail between local users (other than root) fails using sendmail
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Sending mail between local users (other than root) fails using sendmail
I had a working FC7 system on which I installed the Amanda tape backup. Amanda sends reports to root and I want to re-direct mail to a user “Dave” and then collect Dave’s mail from a Windows machine via Dovecot. When I edit the aliases file to re-direct root’s mail to Dave then root’s mail disappears and does not get delivered to Dave!
It was then that I noticed that I couldn’t send mail between local users i.e. I cannot send mail from ‘root’ to ‘Dave’. This would seem to be the first thing to solve. I do not want to send mail externally and I do not want to receive mail from external servers, I assume that I do not need to configure a domain name (or a host name for that matter) – I have tried various configurations and thoroughly confused myself.
I have therefore configured a new virgin install of Fedora 8 with no changes and it shows the same problem. There is obviously something fundamental that I am missing, all the stuff I have read suggests that if sendmail cannot find a host to forward to it will deliver the mail to the user with the same name on the local machine but I seem to have a problem either with User Unknown or Host Unknown!
[root@localhost ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost localhost
::1 localhost6.localdomain6 localhost6
[root@localhost ~]#
sending a mail message to root seems ok
Code:
[root@localhost ~]# echo "test mail" | mail -s Subject root
[root@localhost ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 1 message 1 new
>N 1 root@localhost.local Thu Dec 27 15:02 16/649 "Subject"
& q
Held 1 message in /var/spool/mail/root
With the verbosity option set this still seems OK
Code:
[root@localhost ~]# echo "test mail" | mail -v -s Subject root
root... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.14.1/8.14.1; Thu, 27 Dec 2007 15:04:02 GMT
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<root@localhost.localdomain> SIZE=37 AUTH=root@localhost.localdomain
250 2.1.0 <root@localhost.localdomain>... Sender ok
>>> RCPT To:<root@localhost.localdomain>
>>> DATA
250 2.1.5 <root@localhost.localdomain>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 lBRF42cJ003215 Message accepted for delivery
root... Sent (lBRF42cJ003215 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection
You have mail in /var/spool/mail/root
Sending a mail message to Dave however fails and only results in a message to root informing that the mail failed because dave@localhost.localdomain is unknown however the error message can be sent to root@localhost.localdomain successfully.
Code:
[root@localhost ~]# echo "test mail" | mail -v -s Subject Dave
Dave... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.14.1/8.14.1; Thu, 27 Dec 2007 15:06:15 GMT
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<root@localhost.localdomain> SIZE=37 AUTH=root@localhost.localdomain
250 2.1.0 <root@localhost.localdomain>... Sender ok
>>> RCPT To:<Dave@localhost.localdomain>
>>> DATA
550 5.1.1 <Dave@localhost.localdomain>... User unknown
503 5.0.0 Need RCPT (recipient)
>>> RSET
250 2.0.0 Reset state
>>> RSET
250 2.0.0 Reset state
root... Using cached ESMTP connection to [127.0.0.1] via relay...
>>> MAIL From:<> SIZE=1061
250 2.1.0 <>... Sender ok
>>> RCPT To:<root@localhost.localdomain>
>>> DATA
250 2.1.5 <root@localhost.localdomain>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 lBRF6FXV003224 Message accepted for delivery
root... Sent (lBRF6FXV003224 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection
You have new mail in /var/spool/mail/root
Sending mail to Dave@localdomain seems more successful (emphasis on ‘seems’)
Code:
[root@localhost ~]# echo "test mail" | mail -v -s Subject Dave@localdomain
Dave@localdomain... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.14.1/8.14.1; Thu, 27 Dec 2007 15:08:50 GMT
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<root@localhost.localdomain> SIZE=49 AUTH=root@localhost.localdomain
250 2.1.0 <root@localhost.localdomain>... Sender ok
>>> RCPT To:<Dave@localdomain>
>>> DATA
250 2.1.5 <Dave@localdomain>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 lBRF8o2S003269 Message accepted for delivery
Dave@localdomain... Sent (lBRF8o2S003269 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection
[root@localhost ~]#
but Dave has no mail
Code:
[Dave@localhost ~]$ mail
No mail for Dave
[Dave@localhost ~]$
However root has mail
Code:
[root@localhost ~]# mail
Mail version 8.1 6/6/93. Type ? for help.
"/var/spool/mail/root": 6 messages 5 new 6 unread
U 1 root@localhost.local Thu Dec 27 15:02 17/659 "Subject"
>N 2 root@localhost.local Thu Dec 27 15:04 16/649 "Subject"
N 3 MAILER-DAEMON@localh Thu Dec 27 15:06 67/2315 "Returned mail: see transcript for details"
N 4 MAILER-DAEMON@localh Thu Dec 27 15:08 63/2254 "Returned mail: see transcript for details"
N 5 MAILER-DAEMON@localh Thu Dec 27 15:08 62/2244 "Returned mail: see transcript for details"
N 6 MAILER-DAEMON@localh Thu Dec 27 15:08 63/2254 "Returned mail: see transcript for details"
&
looking at message 6 shows that the error is Host Unknown – From this I deduce that we can submit mail and Sendmail accepts mail for dave@localdomain but that having accepted the mail it does not know what to do with it.
Code:
--lBRF8o2S003271.1198768130/localhost.localdomain
Content-Type: message/delivery-status
Reporting-MTA: dns; localhost.localdomain
Received-From-MTA: DNS; localhost.localdomain
Arrival-Date: Thu, 27 Dec 2007 15:08:50 GMT
Final-Recipient: RFC822; Dave@localdomain
Action: failed
Status: 5.1.2
Remote-MTA: DNS; localdomain
Diagnostic-Code: SMTP; 550 Host unknown
Last-Attempt-Date: Thu, 27 Dec 2007 15:08:50 GMT
--lBRF8o2S003271.1198768130/localhost.localdomain
Content-Type: message/rfc822
Return-Path: <root@localhost.localdomain>
Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by localhost.localdomain (8.14.1/8.14.1) with ESMTP id lBRF8o2S003269
for <Dave@localdomain>; Thu, 27 Dec 2007 15:08:50 GMT
Received: (from root@localhost)
by localhost.localdomain (8.14.1/8.14.1/Submit) id lBRF8oqu003268
for Dave@localdomain; Thu, 27 Dec 2007 15:08:50 GMT
Date: Thu, 27 Dec 2007 15:08:50 GMT
From: root <root@localhost.localdomain>
Message-Id: <200712271508.lBRF8oqu003268@localhost.localdomain>
To: Dave@localdomain
Subject: Subject
test mail
--lBRF8o2S003271.1198768130/localhost.localdomain--
looking at /var/log/maillog shows the same
[root@localhost ~]# vi /var/log/maillog
Dec 27 15:08:14 localhost sendmail[3232]: lBRF8E6e003232: to=Dave@localdomain, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30049, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (lBRF8E2v003233 Message accepted for delivery)
Dec 27 15:08:14 localhost sendmail[3235]: lBRF8E2v003233: to=<Dave@localdomain>, ctladdr=<root@localhost.localdomain> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120341, relay=localdomain, dsn=5.1.2, stat=Host unknown (Name server: localdomain: host not found)
Dec 27 15:08:14 localhost sendmail[3235]: lBRF8E2v003233: lBRF8E2v003235: DSN: Host unknown (Name server: localdomain: host not found)
Dec 27 15:08:14 localhost sendmail[3235]: lBRF8E2v003235: to=<root@localhost.localdomain>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31590, dsn=2.0.0, stat=Sent
Dec 27 15:08:32 localhost sendmail[3240]: lBRF8W9S003240: from=root, size=39, class=0, nrcpts=1, msgid=<200712271508.lBRF8W9S003240@localhost.localdomain>, relay=root@localhost
Dec 27 15:08:32 localhost sendmail[3241]: lBRF8WTs003241: from=<root@localhost.localdomain>, size=331, class=0, nrcpts=1, msgid=<200712271508.lBRF8W9S003240@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Dec 27 15:08:32 localhost sendmail[3240]: lBRF8W9S003240: to=Dave@localdomain, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30039, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (lBRF8WTs003241 Message accepted for delivery)
Dec 27 15:08:32 localhost sendmail[3243]: lBRF8WTs003241: to=<Dave@localdomain>, ctladdr=<root@localhost.localdomain> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120331, relay=localdomain, dsn=5.1.2, stat=Host unknown (Name server: localdomain: host not found)
Dec 27 15:08:32 localhost sendmail[3243]: lBRF8WTs003241: lBRF8WTs003243: DSN: Host unknown (Name server: localdomain: host not found)
Dec 27 15:08:32 localhost sendmail[3243]: lBRF8WTs003243: to=<root@localhost.localdomain>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31580, dsn=2.0.0, stat=Sent
Dec 27 15:08:50 localhost sendmail[3268]: lBRF8oqu003268: from=root, size=49, class=0, nrcpts=1, msgid=<200712271508.lBRF8oqu003268@localhost.localdomain>, relay=root@localhost
Dec 27 15:08:50 localhost sendmail[3269]: lBRF8o2S003269: from=<root@localhost.localdomain>, size=341, class=0, nrcpts=1, msgid=<200712271508.lBRF8oqu003268@localhost.localdomain>, proto=ESMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Dec 27 15:08:50 localhost sendmail[3268]: lBRF8oqu003268: to=Dave@localdomain, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30049, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (lBRF8o2S003269 Message accepted for delivery)
Dec 27 15:08:50 localhost sendmail[3271]: lBRF8o2S003269: to=<Dave@localdomain>, ctladdr=<root@localhost.localdomain> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=120341, relay=localdomain, dsn=5.1.2, stat=Host unknown (Name server: localdomain: host not found)
Dec 27 15:08:50 localhost sendmail[3271]: lBRF8o2S003269: lBRF8o2S003271: DSN: Host unknown (Name server: localdomain: host not found)
Dec 27 15:08:50 localhost sendmail[3271]: lBRF8o2S003271: to=<root@localhost.localdomain>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31590, dsn=2.0.0, stat=Sent
Sendmail.mc shows that sendmail should accept mail for localhost.localdomain which it does.
Code:
[root@localhost ~]# vi /etc/mail/sendmail.mc
dnl #
dnl DAEMON_OPTIONS(`Name=MTA-v4, Family=inet, Name=MTA-v6, Family=inet6')
dnl #
dnl # We strongly recommend not accepting unresolvable domains if you want to
dnl # protect yourself from spam. However, the laptop and users on computers
dnl # that do not have 24x7 DNS do need this.
dnl #
FEATURE(`accept_unresolvable_domains')dnl
dnl #
dnl FEATURE(`relay_based_on_MX')dnl
dnl #
dnl # Also accept email sent to "localhost.localdomain" as local email.
dnl #
LOCAL_DOMAIN(`localhost.localdomain')dnl
dnl #
dnl # The following example makes mail from this host and any additional
dnl # specified domains appear to be sent from mydomain.com
dnl #
dnl MASQUERADE_AS(`mydomain.com')dnl
dnl #
dnl # masquerade not just the headers, but the envelope as well
dnl #
dnl FEATURE(masquerade_envelope)dnl
dnl #
dnl # masquerade not just @mydomainalias.com, but @*.mydomainalias.com as well
dnl #
dnl FEATURE(masquerade_entire_domain)dnl
dnl #
dnl MASQUERADE_DOMAIN(localhost)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl
When Dave sends mail to Dave something very similar happens
Code:
[Dave@localhost ~]$ echo "test" | mail -v -s Subject Dave
Dave... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.14.1/8.14.1; Thu, 27 Dec 2007 15:48:46 GMT
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<Dave@localhost.localdomain> SIZE=32 AUTH=Dave@localhost.localdomain
250 2.1.0 <Dave@localhost.localdomain>... Sender ok
>>> RCPT To:<Dave@localhost.localdomain>
>>> DATA
550 5.1.1 <Dave@localhost.localdomain>... User unknown
503 5.0.0 Need RCPT (recipient)
>>> RSET
250 2.0.0 Reset state
/home/Dave/dead.letter... Saved message in /home/Dave/dead.letter
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection
Code:
[Dave@localhost ~]$ echo "test" | mail -v -s Subject Dave@localdomain
Dave@localdomain... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.14.1/8.14.1; Thu, 27 Dec 2007 15:51:19 GMT
>>> EHLO localhost.localdomain
250-localhost.localdomain Hello localhost.localdomain [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> MAIL From:<Dave@localhost.localdomain> SIZE=44 AUTH=Dave@localhost.localdomain
250 2.1.0 <Dave@localhost.localdomain>... Sender ok
>>> RCPT To:<Dave@localdomain>
>>> DATA
250 2.1.5 <Dave@localdomain>... Recipient o]
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 lBRFpJH6003453 Message accepted for delivery
Dave@localdomain... Sent (lBRFpJH6003453 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection
[Dave@localhost ~]$ mail
No mail for Dave
Have you tried sending mail to a local user whose user-name is all lower case? If the username was steve, with a home directory of /home/steve and a mail spool of /var/spool/mail/steve, try sending mail to each of; steve, steve@localhost and steve@localhost.localdomain.
You shouldn't be able to send to localdomain, because it doesn't resolve. According to your hosts file, localhost will resolve and localhost.localdomain will resolve, but that's all.
Nice one gilead, creating a user with a lower case logon name of steve allows me to send mail from root to steve, steve@localhost & steve@localhost.localdomain which as you correctly point out should all resolve to the user steve on the local machine.
Sending mail to Steve, Steve@localhost & Steve@localhost.localdomain and even sTeve all result in mail successfully being delivered to steve. Somewhere there must be a conversion to lowercase to prevent mail being rejected if incorrectly capitalised.
choogendyk - I haven't edited (yet) the hosts file as far as I know so I assume the reason localhost is in there twice is down to the installer.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.