Postfix配置文档

简介:

环境: RedHat Linux+Postfix+Cyrus-sasl+Dovecot+Stunnel

在安装 Linux 时,如果选择全部安装的话, Postfix Dovecot 以及 Stunnel 将会自动给予安装上去,查看是否已安装,可以执行如下命令:
rpm –qa | grep postfix
dovecot stunnel
如果没有的话,请直接在光盘里找出来,并给予安装。这里以 RPM 包安装为列,安装命令如下:
rpm –ivh postfix-*.rpm  

rpm –ivh cyrus-sasl-*.rpm 

rpm –ivh dovecot-*.rpm 

rpm-ivh stunnel-*.rpm
这里的 * 代表的是相关的版本号。
在确认这些安装包已安装到系统里后,现在开始配置 Mail 服务。
首先,请停止系统内自带的 Mail 服务 -Sendmail ,执行如下命令:
/etc/init.d/sendmail stop      //
先停止 sendmail 进程
chkconfig sendmail off       //
再把自启动服务去掉
一:配置 Cyrus-sasl
确定已安装完 Cyrus-sasl 后,启动该服务:
/etc/init.d/saslauthd start     //
启动 Cyrus-sasl 服务。
chkconfig saslauthd on      //
Cyrus-sasl 设置为开机自启动。
测试一下是否成功:
testsaslauthd –u 
系统用户名  –p ‘ 对应的密码    或
/usr/sbin/testsaslauthd –u 
系统用户名  –p ‘ 对应的密码
如果提示:
0: OK "Success."
则说明已安装成功!
注: Cyrus-sasl 的功能就是实现密码验证机制。
二:配置 SMTP
现在,开始配置 Postfix Postfix 的功能就是实现 SMTP 服务,也即信件发送服务。 Postfix 的主要配置文档是 /etc/postfix/main.cf ,如果没看到 mail.cf 文档则请执行:
cp /etc/postfix/main.cf.default /etc/postfix/main.cf
然后修改 main.cf 的相关内容。具体内容如下:
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.1.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
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_rbl_client cdl.anti-spam.org.cn
                                reject_rbl_client cblplus.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
Postfix
配置文件默认情况下,没有启用 SMTP 认证机制,所以,需要修改 postfix 的主配置 main.cf 文件,也即上面以 smtpd 开头的,这些就是实现 SMTP 功能的配置内容!
现在可以启动 postfix 服务:
/etc/init.d/postfix start       //
启动 postfix 服务
chkconfig postfix on
     // 设置 postfix 开机自启动。
可以通过 netstat –ntl 进行查看 SMTP 的端口 (25) 是否起来。
然后就可以进行测试是否能发信,如果不行的话,请查看一下:
/usr/lib/sasl2
下是否存在着 smtpd.conf Sendmail.conf 两个文件,其内容为:
[root@xtmail sasl2]# cat Sendmail.conf 
pwcheck_method:saslauthd
与:
[root@xtmail sasl2]# cat smtpd.conf 
pwcheck_method: saslauthd
但有时候, Postfix 无法自动找到 saslauthd 的路径,所以需要在 smtpd.conf 里添加一条:
saslauthd_path:/var/run/saslauthd/mux
三:配置 POP3
Dovecot
的功能就是实现收信功能,即 POP3 功能。在安装 Dovecot RPM 包后, Dovecot 的配置文件是在 /etc/ 下的 dovecot.conf
为了能让 Dovecot 正常使用,需要修改一下 dovecot.conf 的些配置。具体如下:
protocols = pop3
pop3_listen = [::]
login = imap
login = pop3
mbox_locks = fcntl
auth = default
auth_mechanisms = plain
auth_userdb = passwd
auth_user = root
完后,请运行以下命令:
/etc/init.d/dovecot start           //
启动 Dovecot 服务
chkconfig dovecot on            //
设置开机自启动
四:端口加密
现在就把一台具有 SMTP POP3 功能的邮局配置完毕。当然了,这台只具备简单的 SMTP POP3 功能的邮局,现在要对其进行端口加密。也就是提到的 Stunnel Stunnel 的配置文件是在 /etc/stunnel/stunnel.conf ,里面已有 SMTP POP3 的进行端口加密。一般只要直接启动起来就可以了。具体形式如下:
/etc/init.d/stunnel      //
启动 stunnel
如果是用 tar.gz 进行编译的话,有时在启动 stunnel 时,需要带上 stunnel.conf 的绝对路径!
五:
现在一套完整的 Postfix 邮局已配置完毕,可以投入正常使用。可以通过  netstat –ntl 进行查看到 25 110 465 995 这几个端口的存在。其中 25 端口加密后就是 465 110 加密后就是 995 110 端口只是一个与客户端连接的,可以禁止掉。 25 端口不可以屏蔽掉,因为 Mail 服务器之间在互相传输时,还是使用 25 端口的。









本文转自 jxwpx 51CTO博客,原文链接:http://blog.51cto.com/jxwpx/233984,如需转载请自行联系原作者
目录
相关文章
|
MySQL 关系型数据库 数据安全/隐私保护
|
存储 网络协议 Linux
Postfix + Extmail 企业邮件服务器搭建
ExtMail套件用于提供从浏览器中登录、使用邮件系统的Web操作界面,而Extman套件用于提供从浏览器中管理邮件系统的Web操作界面。它以GPL版权释出,设计初衷是希望设计一个适应当前高速发展的IT应用环境,满足用户多变的需求,能快速进行开发、改进和升级,适应能力强的webmail系统。
671 0
Postfix + Extmail 企业邮件服务器搭建
|
网络协议 Linux 网络安全
Linux服务器---邮件服务安装postfix
安装postfix      postfix是一个快速、易于管理、安全性高的邮件发送服务,可以配合dovecot实现一个完美的邮箱服务器。1、安装postfix       [root@localhost ~]# rpm -qa | grep postfix      [root@localhos...
2303 0
|
网络协议 测试技术 开发工具
|
网络协议 测试技术 数据安全/隐私保护
|
测试技术 开发工具 数据安全/隐私保护
|
网络协议 安全 关系型数据库
|
Linux 开发工具 数据安全/隐私保护