Linux – Sendmail not sending emails

apache-2.2linuxreverse-dnssendmail

The Apache server I've inherited from my predecessor doesn't send emails. When a web application hosted on the server needs to send an email, it blocks all other processes while it tries to send it (giving the appearance to the user that it's frozen) before it fails.

I issued the following command (replacing MY_EMAIL with a valid email address):

sendmail -vvv MY_EMAIL < email.txt

Which logged the following in /var/spool/mail/root

<MY_EMAIL>... Connecting to [127.0.0.1] via relay...
220 localhost.localdomain ESMTP Sendmail 8.13.8/8.13.8; Tue, 23 Feb 2016 10:10:47 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=53 AUTH=root@localhost.localdomain
250 2.1.0 <root@localhost.localdomain>... Sender ok
>>> RCPT To:<MY_EMAIL>
>>> DATA
250 2.1.5 <MY_EMAIL>... Recipient ok (will queue)
354 Enter mail, end with "." on a line by itself
>>> .
250 2.0.0 u1NAAljf028766 Message accepted for delivery
<MY_EMAIL>... Sent (u1NAAljf028766 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 localhost.localdomain closing connection

I don't have much experience with this, is there anything wrong with this log file?

When I issue the command : mailq the email I've just tried to send has been added to the queue:

                 /var/spool/mqueue (6 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------

u1NA3bgF028698       32 Tue Feb 23 10:04 <root@localhost.localdomain>
                 (host map: lookup (<DOMAIN>): deferred)
                                         <MY_EMAIL>
u1NAAljf028766       32 Tue Feb 23 10:12 <root@localhost.localdomain>
                 (host map: lookup (<DOMAIN>): deferred)
                                         <MY_EMAIL>
u1N9O9Kx027456     2007 Tue Feb 23 09:25 <apache@localhost.localdomain>
                 (host map: lookup (<DOMAIN>): deferred)
                                         <MY_EMAIL>
u1IEBMEa015156     1321 Thu Feb 18 14:12 <apache@localhost.localdomain>
                 (host map: lookup (<DOMAIN>): deferred)
                                         <MY_EMAIL>
u1ID5lfY014306     1319 Thu Feb 18 13:07 <apache@localhost.localdomain>
                 (host map: lookup (<DOMAIN>): deferred)
                                         <MY_EMAIL>
                Total requests: 6

Does (host map: lookup (<DOMAIN>): deferred) mean that this is a DNS issue?

Best Answer

This definitely looks like unconfigured server. First of all, localhost.localdomain is just wrong. Localdomain part must definitely be defined to something real. Second, it looks like this localhost.localdomain host isn't recognized by sendmail as locally deliverable, probably because local-host-names configuration file doesn't comprise it. You can check it by revieweing that file, and by issuing a

sendmail -bv root@localhost.localdomain

command. More is contained in the logs, review them with

grep u1NAAljf028766 /var/log/mailllog.

Anyway, start with configuring /etc/hosts.

Related Topic