Completely remove sendmail

At times it was noted that sendmail on my Debian system was not getting completely removed.

Thing tried:

apt-get remove sendmail*

It worked at times, and didnt at others.

But I were to try:

netstat -tulpn | grep :25
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      27878/sendmail: MTA

I’d find it again.

To find where it came from, I did:

 ls -l /proc/27878/
total 0
-r-------- 1 root root 0 Mar  5 12:47 auxv
-r--r--r-- 1 root root 0 Mar  5 11:58 cmdline
-rw-r--r-- 1 root root 0 Mar  5 12:47 coredump_filter
-r--r--r-- 1 root root 0 Mar  5 12:47 cpusete
lrwxrwxrwx 1 root root 0 Mar  5 12:47 cwd -> (deleted) /var/spool/mqueue
-r-------- 1 root root 0 Mar  5 12:47 environ
lrwxrwxrwx 1 root root 0 Mar  5 11:58 exe -> (deleted) /usr/lib/sm.bin/sendmail

Note that it shows /usr/lib/sm.bin/sendmail

However there is no /usr/lib/sm.bin, but there sure is a /usr/lib/sendmail

So I deleted them, and restarted the apache2 server.

 service apache2 restart
[ ok ] Restarting web server: apache2 ... waiting .
[email protected]:~/imscp# netstat -tulpn | grep :25
[email protected]:~/imscp# netstat -tulpn | grep 'sendmail'

Another thing that worked once was doing this:

chmod ugo=rw /etc/init.d/sendmail

In other words, I prevented it from running. But in the earlier instance there was no entry for sendmail under init.d