postfix邮件系统的调试

王朝other·作者佚名  2008-05-31
窄屏简体版  字體: |||超大  

一般postfix系统基本都是postfix+mysql+sasl+courier-imap+maildrop组成的,其他基本上是加上webmail,mysql的web管理,防垃圾spamassassin,防病毒clamav+amasivd-new等

具体设置可以参照wxy的文章,非常感谢wxy的共享精神。

看到很多fans在配置的时候出现很多问题,却不知道如何调试,攥写本文的目的是为了如何调试postfix系统,作为wxy文章的补充。

先说几个基本的概念:

1、postfix的smtp认证是通过sasl library读取mysql进行认证的,注意是sasl library不是saslauthd,所以通过testsaslauthd并不能正确地调试。

2、courier-imap,courier-maildrop是通过courier-authlib来读取mysql的信息,所以pop3服务,imap服务,maildrop的投递都是通过courier-authlib.

3、新版本的sasl2在认证的时候会把用户名abc@test.com,@后面的当成realm来处理,所以新版本的sasl2通过pam_mysql认证的话将不能支持多域,所以基本都用sasl2的mysql扩展。具体的例子就是wxy的文章postfix_I是通过pam_mysql的,postfix_II是用的sasl2的mysql扩展。

调试postfix系统的时候最好分模块调试,sasl2 library和mysql进行调试,courier-authlib和mysql进行调试,这样就可以把故障点缩小。

1、courier-aulib和mysql的调试很简单,courier-authlib提供了测试程序authtest

# authtest

Usage: authtest [-s service] userid [ password [ newpassword ] ]

# authtest -s smtp xxx@test.com 123456

Authentication succeeded.

Authenticated: xxx@test.com (uid 1001, gid 1001)

Home Directory: /var/mail/

Maildir: test.com/xxx/Maildir/

Quota: (none)

Encrypted Password: (none)

Cleartext Password: 123456

Options: (none)

出现类似这样的提示表示courier-authlib已经成功了,如不成功,仔细检查authmysqlrc,authdaemonrc文件和mysql的socket,包括文件的权限。特别要注意authmysqlrc,authdaemonrc里不能有空格,只能是tab。

2、sasl2 library的调试

sasl2提供了2个测试程序sasl2-sample-server、sasl2-sample-client,一个服务程序,一个客户程序,如果是rpm安装的,在cyrus-sasl-devel包中,如果是编译安装的,在sample目录里。postfix smtp认证是也是通过类似的办法,现启动一个sasl_server,然后在启动一个sasl_client连接sasl_server进行认证。

测试程序sasl2-sample-server、sasl2-sample-client调用的是/usr/lib/sasl2/sample.conf,postfix调用的是smtpd.conf

调试的时候拷贝smtpd.conf成sample.conf

然后运行服务程序sasl2-sample-server

# sasl2-sample-server -s smtpd

trying 10, 1, 6

trying 2, 1, 6

bind: Address already in use

运行客户程序sasl2-sample-client

# sasl2-sample-client -s smtpd -m LOGIN localhost

receiving capability list... recv: {11}

PLAIN LOGIN

PLAIN LOGIN

send: {5}

LOGIN

send: {1}

N

recv: {9}

Username:

please enter an authentication id: abc@test.com

Password:

send: {16}

abc@test.com

recv: {9}

Password:

send: {6}

123456

successful authentication

closing connection

服务端程序应为

accepted new connection

send: {11}

PLAIN LOGIN

recv: {5}

LOGIN

recv: {1}

N

send: {9}

Username:

recv: {16}

abc@test.com

send: {9}

Password:

recv: {6}

123456

successful authentication 'abc@test.com'

closing connection

成功之后把sample.conf 拷贝为smtpd.conf,不成功就检查sasl2的配置。postfix和sasl2的调试

网上还有个脚本叫saslfinger,可以下载下来查查,当然配置不一样出来的结果也不一样,可以作为参考。postfix的设置比较多,一定要心细。

如果courier-authlib通过了的话,courier-imap基本不会出现问题,调试可以用telnet 110端口,如果出现问题的原因大部分在maildir目录,检查目录存在,目录权限等。

linux系统大部分的出错提示都可以在log中看到,仔细分析一下log找出错误的原因。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航