If you ever had to deal with big mailman lists on busy servers you know that sometimes things can go wrong, mails never make it to the intended recipients, bounces start to pop up everywhere and more.
One would imagine that given all the different log files that mailman has there should be sufficient information on them to solve any and all issues but as you probably know already that’s not the case.

 

This is what you normally see on mailman’s logs

delivery to [email protected] failed with code -1: (110, 'Connection timed out')
delivery to [email protected] failed with code -1: (-2, 'Name or service not known')
delivery to [email protected] failed with code -1: Server not connected
delivery to [email protected] failed with code -1: (4 , 'Interrupted system call')
Low level smtp error: (111,'Connection refused')

We can improve that with a simple change and have a mailman logging every SMTP transaction.

Open /usr/local/cpanel/3rdparty/mailman/Mailman/Handlers/SMTPDirect.py with your favorite editor

Search for:

def __connect(self):
self.__conn = smtplib.SMTP()
self.__conn.connect(mm_cfg.SMTPHOST, mm_cfg.SMTPPORT)

Change to:

def __connect(self):
self.__conn = smtplib.SMTP()
self.__conn.set_debuglevel(1)
self.__conn.connect(mm_cfg.SMTPHOST, mm_cfg.SMTPPORT)

Restart mailman

/usr/local/cpanel/3rdparty/mailman/bin/mailmanctl restart

You can now check mailman’s logs

tail -f /usr/local/cpanel/3rdparty/mailman/logs/*

Now you can debug and troubleshoot any issue by checking the log.

The Author