你好,游客 登录 注册 搜索
背景:
阅读新闻

RHEL6.4下搭建Postfix+Dovecot邮件服务器

[日期:2014-05-03] 来源:Linux社区  作者:helloyopp [字体:大 中 小]

三.搭建dovecot收信服务器

1.安装软件包

# yum -y install dovecot

 


2.修改配置文件

# vim /etc/dovecot/dovecot.conf

……

20 #protocols = imap pop3 lmtp

21 protocols = imap pop3

 


# vim /etc/dovecot/conf.d/10-ssl.conf

……

6 #ssl = yes

7 ssl = no //禁用SSL加密

 


3.启动服务

# service dovecot start

# chkconfig dovecot on

# netstat -tulnp | grep dovecot

tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 4377/dovecot

tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 4377/dovecot

tcp 0 0 :::110 :::* LISTEN 4377/dovecot

tcp 0 0 :::143 :::* LISTEN 4377/dovecot

 


4.测试收信服务

# telnet mail.linuxidc.com 110

Trying 192.168.100.1...

Connected to mail.linuxidc.com.

Escape character is '^]'.

+OK Dovecot ready.

user tom

+OK

pass 123456

+OK Logged in.

list

+OK 1 messages:

1 479

.

retr 1

+OK 479 octets

Return-Path: <damao@linuxidc.com>

X-Original-To: tom@linuxidc.com

Delivered-To: tom@linuxidc.com

Received: from localhost (unknown [192.168.100.1])

by mail.linuxidc.com (Postfix) with SMTP id 9B6463FD97

for <tom@linuxidc.com>; Fri, 25 Apr 2014 23:00:32 -0700 (PDT)

subject:Test mail

Message-Id: <20140426060137.9B6463FD97@mail.linuxidc.com>

Date: Fri, 25 Apr 2014 23:00:32 -0700 (PDT)

From: damao@linuxidc.com

To: undisclosed-recipients:;

 


hello,tom

.

quit

+OK Logging out.

Connection closed by foreign host.

 


注意:telnet只是用于测试,在实际应用中基本不会用telnet来收发邮件,而是选择更加直观、简便的图形化软件(Outlook、Foxmail等),或者网页邮箱系统(网易邮箱、新浪邮箱等) 。

 


四.启动SMTP认证,提高邮件系统安全性,减少垃圾邮件

1.安装软件,启用服务

# rpm -q cyrus-sasl

cyrus-sasl-2.1.22-7.el5_8.1

# cat /etc/sasl2/smtpd.conf //主配置文件

pwcheck_method: saslauthd

mech_list: plain login

# service saslauthd start

# chkconfig saslauthd on

# testsaslauthd -u damao -p 123456 -s smtp //检查 saslauthd服务

0: OK "Success."

 


2.修改postfix主配置文件,启用认证

# vim /etc/postfix/main.cf

……

27 mynetworks = 127.0.0.1 //定义本地网络

28 smtpd_sasl_auth_enable = yes //启用SASL认证

29 smtpd_sasl_security_options = noanonymous //阻止匿名发

30 smtpd_recipient_restrictions = //设置收件人过滤

31 permit_mynetworks, //允许来自mynetworks的客户程序

32 permit_sasl_authenticated, //允许已通过sasl认证的用户

33 reject_unauth_destination //拒绝向未授权的目标邮件域发信

 


# service postfix restart

 


3.客户机测试不认证发送外域邮件

# telnet mail.linuxidc.com 25

Trying 192.168.100.1...

Connected to mail.linuxidc.com.

Escape character is '^]'.

220 mail.linuxidc.com ESMTP Postfix

mail from:damao@linuxidc.com

250 2.1.0 Ok

rcpt to:xixi@163.com

554 5.7.1 <xixi@163.com>: Relay access denied //发送外域的发信请求被拒绝

421 4.4.2 mail.linuxidc.com Error: timeout exceeded

Connection closed by foreign host.

所以当用户未通过SMTP认证而向外域发送邮件时,其请求将被拒绝

 


4.客户机测试使用认证登录发送外域邮件

用户认证时,用户名、密码信息需要经过BASE64编码后才被识别,执行命令生成BASE64编码值:

 


# printf damao | openssl base64

ZGFtYW8=

# printf 123456 | openssl base64

MTIzNDU2

 


[root@client Desktop]# telnet mail.linuxidc.com 25

Trying 192.168.100.1...

Connected to mail.linuxidc.com.

Escape character is '^]'.

220 mail.linuxidc.com ESMTP Postfix

auth login //执行认证登录

334 VXNlcm5hbWU6

ZGFtYW8= //输入用户名damao的BASE64编码

334 UGFzc3dvcmQ6

MTIzNDU2 //输入密码123456的BASE64编码

235 2.7.0 Authentication successful

mail from:damao@linuxidc.com

250 2.1.0 Ok

rcpt to:xixi@163.com

250 2.1.5 Ok

data //编写邮件内容

354 End data with <CR><LF>.<CR><LF>

subect:test

test mail

.

250 2.0.0 Ok: queued as 5BFCD3FD16

quit

221 2.0.0 Bye

Connection closed by foreign host.

 


由此可见,用户使用认证登录后才能发送给外域邮件

Postfix 的详细介绍:请点这里
Postfix 的下载地址:请点这里

更多RedHat相关信息见RedHat 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=10

linux
相关资讯       邮件服务器  Postfix Dovecot 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款