Sendmail, please don't break Postfix

As I look after most of the services that run on my server (Titan), I experiement around with new scripts, plugins and other bits and pieces.

But there can be times where it does more damage than good.

I wanted to install a CMS (Which I will not name), but it decided that it wanted to install SendMail, which is fine because it was part of this package.
What I didn’t realise that when it installs SendMail, it uninstalls Postfix.

I use postfix for all my entire email set up (Managing email addresses & logins).

So, me being me, I uninstalled sendmail sudo apt remove sendmail – All good! Sendmail is not on my system…but now I can’t establish an SMTP connection on my MS Outlook.

What gives?

I attempted to do sudo service postfix start and that wall showed up OK.
sudo service postfix status showed that it was started but I still couldn’t make an SMTP connection.

I ran netstat -tulpn to find out what ports were open. Sometimes you can find out what process is using that port, but in this instance, it showed.

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN      -

Hmm, that looks ok…

So after a bit of digging around and trying to adjust postfix configs, I decided to stop postfix sudo service postfix stop and re-ran netstat -tulpn

Result:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN      -

O_O…What…But I STOPPED Postfix
How can it still be listening on 587 if there is no service???!?!?!

With a bit of headscratching, I ran netstat -tulpn | grep :587 and it returned:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:587             0.0.0.0:*               LISTEN      15463/sendmail

But…I uninstalled sendmail … How? Anyway, I couldn’t sudo service stop sendmail cause it was already gone, so I did the old kill -9 <pid> trick and that indeed killed it! Ran sudo service postfix start and we are back in action.

A valuable lesson learned today!

TL;DR – Sendmail doesn’t stop the service even if you uninstall, so you have to kill the process BEFORE uninstalling it.