您的位置:首页 > 职场人生

postfix 基本配置

2009-08-04 20:48 274 查看
[align=left][/align]
[align=left]环境:RedHat AS4+Postfix+Cyrus-sasl+Dovecot[/b][/align]
[align=left]在安装Linux时,如果选择全部安装的话,Postfix与Dovecot将会自动给予安装上去,查看是否已安装,可以执行如下命令:

rpm –qa | grep postfix或dovecot

如果没有的话,请直接在光盘里找出来,并给予安装。这里以RPM包安装为列,安装命令如下: [/align]

[align=left]rpm –ivh postfix-*.rpm 或
rpm –ivh cyrus-sasl-*.rpm 或
rpm –ivh dovecot-*.rpm 或[/align]
[align=left]这里的*代表的是相关的版本号。
在确认这些安装包已安装到系统里后,现在开始配置Mail服务。
首先,请停止系统内自带的Mail服务-Sendmail,执行如下命令: [/align]

[align=left]/etc/init.d/sendmail stop //先停止sendmail进程
chkconfig sendmail off //再把自启动服务去掉[/align]
[align=left]一:配置Cyrus-sasl

确定已安装完Cyrus-sasl后,启动该服务: [/align]

[align=left]/etc/init.d/saslauthd start //启动Cyrus-sasl服务。
chkconfig saslauthd on //把Cyrus-sasl设置为开机自启动。[/align]
[align=left]测试一下是否成功: [/align]

[align=left]testsaslauthd –u 系统用户名 –p ‘对应的密码’或
/usr/sbin/testsaslauthd –u 系统用户名 –p ‘对应的密码’[/align]
[align=left]

如果提示:
0: OK "Success."
则说明已安装成功!
注:Cyrus-sasl的功能就是实现密码验证机制。[/align]
[align=left]二:配置DNS[/b][/b][/align]
[align=left]建立DNS邮件记录,将mail.benet.com 配置为邮件服务器。

三:配置SMTP

现在,开始配置Postfix,Postfix的功能就是实现SMTP服务,也即信件发送服务。Postfix的主要配置文档是/etc/postfix/main.cf,如果没看到mail.cf文档则请执行: [/align]

[align=left]cp /etc/postfix/main.cf.default /etc/postfix/main.cf[/align]
[align=left]然后修改main.cf的相关内容。具体内容如下: [/align]

[align=left]alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
header_checks = regexp:/etc/postfix/header_checks
html_directory = no
mailbox_size_limit = 102400000
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = 域名
myhostname = mail.域名
mynetworks = 192.168.0.0/24, 127.0.0.0/8, 192.168.1.100/32
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
readme_directory = /usr/share/doc/postfix-1.1.11/README_FILES
relay_domains = nanoconcept.net
sample_directory = /usr/share/doc/postfix-1.1.11/samples[/align]
[align=left]#############SMTP######################
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain= ''
smtpd_recipient_restrictions =
permit_sasl_authenticated,
permit_auth_destination,
permit_mynetworks,
check_relay_domain,
reject_rbl_client yahoo.com.tw,
reject_rbl_client cbl.anti-spam.org.cn,
reject_non_fqdn_sender,
reject_non_fqdn_recipient,
reject_unknown_sender_domain,
reject_unknown_recipient_domain,
reject(最好在一行写完)
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_recipient_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options=noanonymous
unknown_local_recipient_reject_code = 550[/align]
[align=left]
Postfix配置文件默认情况下,没有启用SMTP认证机制,所以,需要修改postfix的主配置main.cf文件,也即上面以smtpd开头的,这些就是实现SMTP功能的配置内容!

现在可以启动postfix服务: [/align]

[align=left]/etc/init.d/postfix start //启动postfix服务
chkconfig postfix on//设置postfix开机自启动。[/align]
[align=left]可以通过netstat –ntl进行查看SMTP的端口(25)是否起来。

然后就可以进行测试是否能发信,如果不行的话,请查看一下:

/usr/lib/sasl2下是否存在着smtpd.conf与Sendmail.conf两个文件,其内容为: [/align]

[align=left][root@xtmail sasl2]# cat Sendmail.conf
pwcheck_method:saslauthd
与:
[root@xtmail sasl2]# cat smtpd.conf
pwcheck_method: saslauthd[/align]
[align=left]但有时候,Postfix无法自动找到saslauthd的路径,所以需要在smtpd.conf里添加一条: [/align]

[align=left]saslauthd_path:/var/run/saslauthd/mux[/align]
[align=left]三:配置POP3
Dovecot的功能就是实现收信功能,即POP3功能。在安装Dovecot的RPM包后,Dovecot的配置文件是在/etc/下的dovecot.conf

为了能让Dovecot正常使用,需要修改一下dovecot.conf的些配置。具体如下: [/align]

[align=left]protocols = pop3
pop3_listen = [::]
login = imap
login = pop3
mbox_locks = fcntl
auth = default
auth_mechanisms = plain
auth_userdb = passwd
auth_user = root[/align]
[align=left]完后,请运行以下命令: [/align]

[align=left]/etc/init.d/dovecot start //启动Dovecot服务
chkconfig dovecot on //设置开机自启动[/align]
四:检查端口是否正常开启现在一套完整的Postfix邮局已配置完毕,可以投入正常使用。可以通过 netstat –ntl进行查看到25、110、465、995这几个端口的存在。其中25端口加密后就是465,110加密后就是995,110端口只是一个与客户端连接的,可以禁止掉。25端口不可以屏蔽掉,因为Mail服务器之间在互相传输时,还是使用25端口的。
五:测试[/b]
[/b]
[/b]# telnet localhost 25 (远程连接到localhost端口为25)
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 mail.benet.com ESMTP "Version not Available"
ehlo mail.benet.com (测试fandy.com是否正常)
250-mail.benet.com
250-PIPELINING
250-SIZE 14336000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
quit (退出本次测试)
221 Bye
Connection closed by foreign host.

# telnet localhost 110 (远程连接到localhost端口为110)
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK dovecot ready.
quit (退出本次测试)
+OK Logging out
Connection closed by foreign host.

当用 telnet mail.benet.com 25 时出现错误,连接不上,解决方法
在main.cf 中修改:inet_interfaces = localhost
改为: inet_interfaces = all ,问题解决
[/b]
进行测试[/b][/b]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  职场 休闲 postfix