ConfigServer Services HelpDesk
Server Management Services from Way to The Web Ltd
ConfigServer Home Page

Mail processing and delivery seems very slow and there are a lot of emails in the queue

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
Check for Problems

First make sure you have the latest versions and that there is no underlying problem:

1. Ensure you are running the latest versions of MailScanner and the MailScanner Front-end. Instructions for upgrading can be found in this FAQ entry.

2. Make sure that there are no actual problems with MailScanner by tailing /var/log/maillog to check for any errors, looping, etc. Certain types of problems can sometimes lead to MailScanner causing high server loads.

tail -f /var/log/maillog
If you see errors, or MailScanner is not processing any mail at all, see this FAQ for some suggestions,

3. Check to see how many mails are currently waiting to be processed by MailScanner, using either ConfigServer Mail Queues, MailScanner Front-End, or at the command line with:

exim -bpc
If the queue is quite large, you may want to consider temporarily disabling scanning in order to get the pending mail processed, before trying to resolve any possible problems. To do this, go to WHM > ConfigServer MailScanner FE > MailScanner Performance > Disable Scan Messages. When the queue is back down to 0 or close to it, you can Enable Scan Messages again.

Important Note: Disabling scanning of messages and disabling MailScanner are not the same and do not result in the same outcome. If you click "Disable MailScanner" in WHM > ConfigServer MailScanner FE, MailScanner will no longer be processing mail and mail will be going straight through exim, but any mails that were waiting in the MailScanner pending queue will NOT be processed until MailScanner is either re-enabled or uninstalled from the server. If you click "Disable Scan Messages" in WHM > ConfigServer MailScanner FE > MailScaner Performance, MailScanner will continue to process all the mail in the MailScanner pending queue but will not perform any checks on the mail. Therefore if you need the mail in the pending queue to be processed quickly, you should Disable Scan Messages and should not Disable MailScanner.

4. Check DNS lookup speed. Make sure you are using your local resolver, i.e. on the server if you're running a caching nameserver. Check to make sure that is resolving quickly by doing a dig on a random domain name. Slow DNS lookups can drastically slow down spamassassin and therefore mail processing.

5. Ensure you are not using excessive spamassassin rules. The more rules that have to be tested, the longer spamassassin will take to check each message. We no longer recommend using the SARE rules because most of the good ones have been incorporated into the core spamassassin rules.

6. Make sure you are using :fail:, not :blackhole:, not /dev/null, and no spelling mistakes for all default aliases in /etc/valiases.

7. Make sure the SpamAssassin Bayes database is not too large, and delete it if it is too large. Check in MailWatch > Tools > SpamAssassin Bayes Database Info for the number of tokens (less than 500,000 is best), last journal sync and last expiry. Expiry should be getting done on a daily basis. If the bayes database is very large, it would be best to delete it and start over:

rm -Rvf /var/spool/mqueue/.spamassassin
8. Check the size of the MailScanner MySQL database (used for Mail Control), for example in phpMyAdmin. If it is very large, consider reducing the number of days that data is kept (WHM > ConfigServer MailScanner FE > MailScanner Front-end > "Keep x days of MailWatch MySQL database entries"), or remove and recreate the database to start over:


mysql -e "drop database mailscanner"
/usr/mscpanel/mailcontrol/dbadd.pl
9. You can test spamassassin to see if it is hanging on anything in particular, by first saving a complete spam email (including all headers) in a text file on your server (i.e. spam.txt), and running this command on it:

/usr/local/cpanel/3rdparty/bin/spamassassin -tD < spam.txt
If processing slows down or stops at any particular point that may give you clues as to where the problem is.

10. General server checks. Make sure that other major daemons are optimised, for example mysql and apache, to ensure they are not using excessive resources. Also make sure that your disks have plenty of free space and there are no actual hardware problems.

Performance Tweaks

Once you are sure all programs are up to date and there are no actual errors or problems, there are several MailScanner performance tweaks you can try to reduce MailScanner's processing time and improve performance:

1. Do RBL checking in exim rather than MailScanner. This will block any RBL-listed IP addresses immediately in exim rather than sending them to MailScanner for processing, which may help reduce resource usage. Instructions are in this FAQ.

2. Increase the number of MailScanner child processes if your server has sufficient resources. Go to WHM > ConfigServer MailScanner FE > MailScanner Configuration > Max Children. If this is set to 3 (the default) try setting it to 4. If your server is a VPS you should probably not run more than 2 child processes.

3. Disable Dangerous Content scanning. Go to WHM > ConfigServer MailScanner FE > MailScanner Performance > Disable Content Scanning or Disable File Scanning.

4. Upgrade your server. If you have done all of the above, ensured there is no underlying problem and tried all the performance tweaks, and your server is still not able to keep up with the email traffic, then you are asking too much of it and need to either upgrade the server (for instance add more memory), reduce the load on your server by moving some accounts elsewhere, or remove MailScanner as it would appear that MailScanner is not suitable for your server environment.

Share via

Related Articles


Self-Hosted Help Desk Software by SupportPal
© ConfigServer Services