官术网_书友最值得收藏!

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
    
  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"
    
  4. Use grep -v to filter/remove selected logs:
    $ tail -f /var/log/mail.log | grep -v "dovecot"
    
  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 useremail@example.com
    
  9. If you have set virtual users, check if they are working properly:
    $ postmap -q bob@example.org 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
    
  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

主站蜘蛛池模板: 广昌县| 金华市| 沧源| 邛崃市| 正安县| 安乡县| 辽宁省| 沅江市| 西林县| 龙州县| 海晏县| 日照市| 彭泽县| 乐山市| 湟源县| 信宜市| 保康县| 莫力| 岳普湖县| 天津市| 故城县| 嘉禾县| 柏乡县| 海南省| 仁怀市| 孟村| 伊川县| 沂水县| 沁水县| 上饶县| 怀来县| 绥棱县| 朝阳县| 遵化市| 龙陵县| 鸡泽县| 曲水县| 江永县| 淮南市| 旌德县| 赤峰市|