sendmail Stopped Working; What Is Preventing Listening?
Oct 25 04:26:45 woody sendmail[6662]: u9P4QjGc006662: from=fail2ban, size=2693, class=0, nrcpts=1, msgid=<201610250426.u9P4QjGc006662@example.com>, relay=root@localhost
Oct 25 04:26:45 woody sendmail[6662]: u9P4QjGc006662: to=linode@m.example.com, delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=32693, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
I tried apt-get remove sendmail and then apt-get install sendmail and no change.
I then spun up a fresh instance of Ubuntu 16.04.1 LTS; called apt-get install sendmail and sendmail worked.
I then focused on netstat -l between the two systems
Stock install before installing sendmail
> Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:ssh *:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
Stock install after installing sendmail
> tcp 0 0 localhost:submission : LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 localhost:smtp : LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
Broken system after all my efforts
> tcp 0 0 localhost:mysql : LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 [::]:https [::]:* LISTEN
What is preventing localhost:submission and localhost:smtp from appearing on the broken system?
On the working system I see sendmail-mta in the list from ps -e. On the broken system it's not there.
When I run sendmail start & on the broken system it appears briefly as sendmail and then goes away.
I then focused on trying to do a clean install of sendmail. I executed the following:
apt-get remove sendmail
apt-get purge sendmai
apt autoremove
rm /etc/mail/sendmail*
apt-get install sendmail
I was hoping doing so would re-create the config files but it did not. ls /etc/mail/send* has 0 results.
6 Replies
I'm thinking the issue is that fail2ban is blocking your server from, well, communicating with itself. (?!).
What makes me think that is this:
Connection refused by [127.0.0.1]
I would check the ban list, but if nothing seems to be coming up, I'd say test by disabling fail2ban and restart sendmail. If it works, cool! If not, then check the mailing log again and see if any new errors come up.
If it so happens to be fail2ban being the issue, just whitelist your IP address (public and private) and you should be good:
Good luck.
Also, can you try whitelisting your IP address:
@invalidptr:
Something is restarting fail2ban. I execute fail2ban-client stop and then ps -e | grep fail shows it with a new PID. Any ideas how to stop this?
Use "sudo service fail2ban stop". You're doing it from the client, perhaps the new systemd thinks fail2ban crashed and is restarting it. IDK.
Also, one of your posts suggested that sendmail isn't listening at all. Even if fail2ban had put its IP (I guess localhost from your posts) in a jail; sendmail should still be listening either way.
Also, sendmail isn't the best email mailer option, Google "sendmail or postfix". I highly recommend Postfix.
Also, your idea to spin up a separate known good instance is an excellent debugging/troubleshooting technique.
FWIW I'm using sendmail based on this Linode article