24/7/365 Support

Troubleshooting the mail server on Ubuntu

Sometimes you may face problems such as e-mails not being sent, delayed delivery or mail bouncing, issues while fetching e-mails, and login failures. In this recipe, we will learn how to identify the exact problem behind these issues. We will learn how to use debugging tools and read the logs of Postfix and Dovecot.

Getting ready

You will need access to a root account or an account with sudo privileges.

It is assumed that you have already installed Postfix and Dovecot servers.

How to do it…

Follow these steps to troubleshoot the mail server:

Start with checking the status of Postfix and Dovecot. If you get output that says stop/waiting or not running then the respective service is not running:

$ sudo service postfix status

$ sudo service dovecot status

Try to restart the respective services. Restarting may give you error messages. Also check for startup logs under /var/log/mail.log:

$ sudo service postfix restart

$ less /var/log/mail.log

You can use a tail command to monitor the stream of logs while the service is running. You can easily filter the output of tail by piping it to a grep command:

$ tail -f /var/log/mail.log

Use grep to only view selected logs:

$ tail -f /var/log/mail.log | grep "dovecot"

Use grep -v to filter/remove selected logs:

$ tail -f /var/log/mail.log | grep -v "dovecot"

You can check other log files such as /var/log/mail.err and /var/log/upstart/dovecot.log.

You may want to enable verbose logging to get detailed debugging information. To enable debug mode on Dovecot, edit 10-logging.conf and enable auth_verbose and mail_debug variables:

$ sudo nano /etc/dovecot/conf.d/10-logging.conf

auth_verbose = yes

mail_debug = yes

Restart Dovecot:

$ sudo service dovecot restart

To enable verbose logging on Postfix, edit master.cf file and add the -v argument:

$ sudo nano /etc/postfix/master.cf

smtp inet n - - - - smtpd -v

Restart Postfix.

Turn off chroot operations:

$ sudo nano /etc/postfix/master.cf

smtp inet n - n - - smtpd

Check user account with Dovecot:

$ doveadm username useremail@example.com

If you have set virtual users, check if they are working properly:

$ postmap -q bob@example.org mysql:/etc/postfix/mysql-virtual- maps

Check respective ports used by Postfix and Dovecot. Postfix uses ports 25, 465, 587 and Dovecot uses port 993 and 995:

$ telnet localhost 993

Check netstat to make sure services are listening:

$ sudo netstat -plutn

Check for DNS resolution and MX records:

$ host -t mx example.com

Check if spam filters and antivirus scanners are working properly.

See also

Postfix debugging - http://www.postfix.org/DEBUG_README.html

Postfix book (troubleshooting) at http://www.postfix-book.com/debugging.html

Dovecot troubleshooting at http://wiki2.dovecot.org/WhyDoesItNotWork

Help Category:

What Our Clients Say