Troubleshooting the mail server

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:

  1. 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
    
    How to do it…
  2. 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
    
  3. 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"
    
    How to do it…
  4. Use grep -v to filter/remove selected logs:
    $ tail -f /var/log/mail.log | grep -v "dovecot"
    
    How to do it…
  5. 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
    
  6. 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.

  7. Turn off chroot operations:
    $ sudo nano /etc/postfix/master.cf
    smtp      inet  n       -       n       -       -       smtpd
    
  8. Check user account with Dovecot:
    $ doveadm username [email protected]
    
  9. If you have set virtual users, check if they are working properly:
    $ postmap -q [email protected] mysql:/etc/postfix/mysql-virtual-maps
    
  10. Check respective ports used by Postfix and Dovecot. Postfix uses ports 25, 465, 587 and Dovecot uses port 993 and 995:
    $ telnet localhost 993
    
  11. Check netstat to make sure services are listening:
    $ sudo netstat -plutn
    
    How to do it…
  12. Check for DNS resolution and MX records:
    $ host -t mx example.com
    
  13. Check if spam filters and antivirus scanners are working properly.

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset