Linux-Postfix+Dovecot+Postfixadmin+Roundcubemail 搭建邮件服务器管理系统(四)

实现 SMTP 发信认证

1、 启动 saslauthd 认证服务

[root@mail ~]# yum  -y  install  cyrus-sasl        //此包默认通常已安装
[root@mail ~]# systemctl restart saslauthd 
[root@mail ~]# systemctl enable saslauthd
[root@mail ~]# testsaslauthd  -u user01  -p test1234  -s  smtp
0: OK "Success."                                    //检查saslauthd服务

2、编辑 postfix 配置,启用SMTP认证

[root@mail ~]# vim  /etc/postfix/main.cf
# 设置本地网络
mynetworks = 127.0.0.1
# 启用SASL认证
smtpd_sasl_auth_enable = yes
# 阻止匿名发信
smtpd_sasl_security_options = noanonymous
# 拒绝向未授权的目标域发信
smtpd_recipient_restrictions = permit_mynetworks,  permit_sasl_authenticated, reject_unauth_destination                       
[root@mail ~]# systemctl restart saslauthd 

3、以用户user01为例,未经过认证登录时,向外域发邮件会被拒绝

[root@mail ~]# telnet mail.auto.com 25
Trying 127.0.0.1...
Connected to mail.auto.com (127.0.0.1).
Escape character is '^]'.
220 mail.xxx.com ESMTP Postfix
HELO localhost                                                    //  宣告本机地址
250 mail.auto.com
MAIL FROM:user01@auto.com                           // 指定发件人地址
250 2.1.0 Ok
RCPT TO:test@126.com                                   //  指定收件人地址
454 4.7.1 <test@126.com>: Relay access denied 
                                                                        //  发送外域的发信请求被拒绝
quit                                                                //  断开telnet连接
221 2.0.0 Bye
Connection closed by foreign host.
  • 为用户user01为例,生成用户名、密码的加密字串
[root@mail ~]# printf  "user01" | openssl  base64
bmljaw==
[root@mail ~]# printf  "test1234" | openssl  base64
MTIzNDU2Nw==
  • 认证登录通过以后,才允许向外域发邮件
[root@mail ~]# telnet mail.auto.com 25

Trying 127.0.0.1...
Connected to mail.xxx.com (127.0.0.1).
Escape character is '^]'.
220 mail.xxx.com ESMTP Postfix
EHLO localhost                              //加密宣告本机地址
250-mail.xxx.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH LOGIN                                 //声明要执行认证登录
334 VXNlcm5hbWU6
bmljaw==                                   //输入用户名xxx的BASE64编码
334 UGFzc3dvcmQ6
MTIzNDU2Nw==                               //输入密码1234567的BASE64编码
235 2.7.0 Authentication successful
MAIL FROM:user01@xxx.com                    //指定发件人地址
250 2.1.0 Ok
RCPT TO:test@126.com                   //指定收件人地址
250 2.1.5 Ok
DATA                                       //开始编写邮件内容
354 End data with <CR><LF>.<CR><LF>
Subject:SMTP Auth Test                     //指定邮件标题
  Hello, here is a test mail.              //输入文本邮件内容
.                                          //独立的 . 表示输入完毕
250 2.0.0 Ok: queued as 8C48431D8B2
quit                                       //断开telnet连接
221 2.0.0 Bye
Connection closed by foreign host.
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值