使用postfix的一些问题记录

在使用postfix时,也遇到一些配置相关的各种问题,在这里简单记录一下。关于我在测试系统中使用的postfix的main.cf配置文件,在:https://github.com/smilejay/other-code/blob/master/config/postfix_main.cf

在CentOS 6.x 系统中,
postfix主配置文件为/etc/postfix/main.cf
postfix默认的日志在:/var/log/maillog,常用 tail -f /var/log/maillog 来实时观察postfix的log。

问题1:看到一些IPv6地址网络连不上的问题,比如给gmail发邮件时,有如下错误:
Jun 29 14:59:00 qa-test postfix/smtp[20040]: connect to ASPMX.L.GOOGLE.com[2607:f8b0:400e:c03::1b]:25: Network is unreachable
解决方法:在/etc/postfix/main.cf中,添加或修改为仅支持IPv4,如下:
inet_protocols = ipv4
重启postfix服务,正常的log应该如下:
Jun 29 16:03:00 qa-test postfix/smtpd[22396]: disconnect from unknown[192.168.1.2]
Jun 29 16:03:29 qa-test postfix/smtp[22409]: D27441A0040: to=, relay=ASPMX.L.GOOGLE.com[74.125.25.26]:25, delay=29, delays=0.01/0.01/28/0.75, dsn=2.0.0, status=sent (250 2.0.0 OK 1404029009 lo8si19318969pab.161 - gsmtp)

问题2:使用SMTP的用户名/密码验证才能发送邮件。
解决方法:配置文件中添加如下内容,然后重启postfix服务。
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = ''
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous

具体怎么设置用户名和密码呢?
首先,编辑/etc/sysconfig/saslauthd 文件,设置如下:
MECH=shadow
用命令 service saslauthd restart 重启saslauthd服务。
然后,添加用户并设置密码(如:user/1234)

问题3:在某些时候,想发送很大的附件,可能会遇到错误,看log中有如下信息:
Oct 28 23:42:29 smilejay postfix/sendmail[16236]: fatal: smile665@gmail.com(48): message file too big
Oct 28 23:42:31 smilejay postfix/postdrop[16245]: warning: uid=48: File too large
解决方法:
vim etc/postfix/main.cf 添加如下一行:
message_size_limit = 102400000
然后重启postfix。
不过还可能继续碰到如下错误:
Oct 29 00:55:51 smilejay postfix/local[18986]: fatal: main.cf configuration error: mailbox_size_limit is smaller than message_size_limit
那么,需要将mailbox的大小限制也要设置为更大,示例如下:
mailbox_size_limit = 204800000

配置时参考了这个文档:http://www.linuxidc.com/Linux/2012-12/75603.htm

master

Stay hungry, stay foolish.

发表评论

邮箱地址不会被公开。 必填项已用*标注

*