How to debug Postfix?

If you’ve read about my tutorial on setting up Postfix, you should be able to send and receive emails now. But life never goes smooth always.  You may encounter this or that problem in using the email system. To solve problems quickly, you need some tips of debugging postfix. The log file (/etc/log/maillog) is the main source to find useful information about problems. You can read this article on analyzing the log file. This is an in-depth article which is much better than the lengthy/tedious/not accurate  Q&As on stackoverflow. To get more information, you can add the following lines in main.cf

Postfix will generate more logs when it handles emails with the peer(xx.xx.xx.xx is the ip address of the peer). You can send an email from the ip address you specify as the debug_peer_list parameter, then read /var/log/maillog to see what happened. If you’ve known which specific daemon is making trouble, you can turn the verbose mode on for that daemon in master.cf. For example, the following will make smtpd to generate even more logs in /var/log/maillog.

Here are some tips on reading the log file:

  1. First, find the line “connect from…” is where email receiving/relaying begins.
  2. Second, the lines containing “>”  are where postfix sends messages to the peer. You can see the messages postfix sends in those lines.
  3. Third, the lines containing “<” are where posfix receives messages from the peer. Also you can check what messages are being received on those lines.
  4. Fourth, the lines containing “>>>…<<<” are where postfix checks the rules in main.cf. For example, the following line indicates postfix is verifying the rule:smtpd_recipient_restrictions =xxxx

>>> START Recipient address RESTRICTIONS <<<

Finally, I recommend you read this official debug guide .

 

 

Posted in tips of hosting