# mailq /var/spool/mqueue is empty Total requests: 0 #
I tried sending a test message from the mail sever to an
external email account with the mailx command. For the body of the message, I put some text into a file
named test.txt
and used the <
character to
provide the contents of the
file as input to mailx for the body of the message. I didn't receive
any error message and I didn't see any messages stuck in the mail queue
when I checked it after I sent the message. But the message was not received
at the destination email account.
# mailx -s "Testing" moonpoint@example.com <test.txt # mailq /var/spool/mqueue is empty Total requests: 0 #
So I then used the sendmail command, instead, to send a test message to see if it would provide me with any information that I could use for troubleshooting the problem. I created a file with the following contents to send as a test message.
# cat temp.txt Subject: Sendmail test This is a test. This is only a test.
You can send a test message whose contents are contained in a text file
from a command line interface using a
sendmail command in
the form sendmail recipient_email_address <
input_file
. But when I did that, I saw a "Connection
refused by [127.0.0.1]" message.
# sendmail moonpoint@example.com < temp.txt # sendmail -v moonpoint@example.com < temp.txt moonpoint@example.com... Connecting to [127.0.0.1] via relay... moonpoint@example.com... Deferred: Connection refused by [127.0.0.1] #
You can also send a message with the content for the body of the message typed after you issue the command as shown below, though in this case, since there was a problem with sendmail, I received the "Connection refused by [127.0.0.1]" message. After you issue the command, you won't see a prompt, but you can type text for the body of the message. Hit Enter to start a new line in the message and hit Ctrl-D when you are finished entering text for the body of the message to send the message.
# sendmail -v moonpoint@example.com A test message. moonpoint@example.com,Test,Message... Connecting to [127.0.0.1] via relay... moonpoint@example.com,Test,Message... Deferred: Connection refused by [127.0.0.1] #
After I saw the "Connection refused by [127.0.0.1]" message, I checked to verify that sendmail was running by attempting to connect to the Simple Mail Transfer Protocol (SMTP) port, which is TCP port 25. The netstat command did not show any process listening for connections on that port. I also tried a Telnet connection to that port, which I expected to fail, since netstat wasn't showing any process listening on that port; I received a "connection refused" message when I attempted to connect to port 25 on the localhost address, 127.0.0.1. But I did find that the system was listening on the Post Office Protocol version 3 (POP3) port, port 110, and on the secure POP3 port, port 995, aka the pop3s port.
# netstat -a | grep -i smtp # telnet 127.0.0.1 25 Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused # # netstat -a | grep -i pop3 tcp 0 0 0.0.0.0:pop3s 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:pop3 0.0.0.0:* LISTEN tcp6 0 0 [::]:pop3s [::]:* LISTEN tcp6 0 0 [::]:pop3 [::]:* LISTEN unix 2 [ ACC ] STREAM LISTENING 1398391 /var/run/dovecot/login/pop3
The user who reported the problem to me told me that she normally gets a fair amount of spam, but this morning when she checked her email, though her email client didn't report any problems in checking email, she didn't receive any messages. Since Sendmail wasn't listening on port 25, though, no other email server would have been able to deliver email to the system, so no one on the system would have been receiving email from other email servers.
I started sendmail to resolve the problem and verified the system was then listening on the SMTP port.
# service sendmail start Redirecting to /bin/systemctl start sendmail.service # netstat -a | grep -i smtp | head -n 1 tcp 0 0 0.0.0.0:smtp 0.0.0.0:* LISTEN #
I then sent another test message with sendmail. I used the -v
option to get verbose information regarding the transmission of
the email. This time, after I hit Ctrl-D after typing some text for
the body of the message, I saw much more information and the message was
successfully sent to the recipient email address and I saw it in the inbox for
the recipient account.
$ sendmail -v moonpoint@example.com Still testing. moonpoint@example.com... Connecting to [127.0.0.1] via relay... 220 moonpoint.com ESMTP Sendmail 8.14.7/8.14.7; Mon, 25 Jul 2016 11:43:11 -0400 >>> EHLO moonpoint.com 250-moonpoint.com Hello localhost [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:<jdoe@moonpoint.com> SIZE=15 AUTH=jdoe@moonpoint.com 250 2.1.0 <jdoe@moonpoint.com>... Sender ok >>> RCPT To:<moonpoint@example.com> >>> DATA 250 2.1.5 <moonpoint@example.com>... Recipient ok 354 Enter mail, end with "." on a line by itself >>> . 250 2.0.0 u6Q1S2a4011079 Message accepted for delivery moonpoint@example.com... Sent (u6Q1S2a4011079 Message accepted for delivery) Closing connection to [127.0.0.1] >>> QUIT 221 2.0.0 moonpoint.com closing connection $
I thought the system might have rebooted due to a recent brief power outage and that sendmail might not have restarted afterwards, but when I checked the date of the last reboot, I found it was weeks ago, so that wasn't the cause for sendmail not running.
$ last reboot | head -n 1 reboot system boot 3.10.0-229.7.2.e Fri Jul 1 19:04 - 21:05 (24+02:00) $