测试端口

Test-NetConnection -ComputerName 8.130.131.37 -Port 25

配置main.cf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 邮件服务器名称
myhostname = mail.example.com
# 域名
mydomain = example.com
# 邮件服务器的IP地址
myorigin = $mydomain
# 允许的发送者和接收者
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128

# 邮件服务监听的网络接口
inet_interfaces = all
# 邮件服务监听的端口
inet_protocols = ipv4

telnet测试

telnet mail01.ganxy03.cn 25
HELO mail01.ganxy03.cn

MAIL FROM: root@ganxy03.cn
RCPT TO: 2192767718@qq.com

开启smtp验证

安装 dovecot

yum install -y dovecot

1
2
3
4
5
6
7
8
9
10
11
12
13
14
smtpd_sasl_type = dovecot:指定SASL认证方式使用Dovecot
smtpd_sasl_path = private/auth:指定SASL的认证路径
smtpd_sasl_auth_enable = yes:开启SMTP AUTH认证
smtpd_sasl_security_options = noanonymous:禁用匿名登录
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject:限制收件人的规则


添加sasl认证
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_application_name = smtpd
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination

测试发送

echo "邮件正文" | mail -s "邮件主题" 收件人邮箱地址

echo "测试内容" | mail -s "邮件测试" [email protected]

echo "测试内容" | mail -s "邮件测试" [email protected]

身份验证

telnet mail01.ganxy03.cn 25
HELO mail01.ganxy03.cn

AUTH LOGIN

cm9vdA==

YWJjMTM3MzU4MjAyNDQ=
mail from: 2192767718@qq.com
MAIL FROM: root@ganxy03.cn
RCPT TO:2192767718@qq.com

RCPT TO: 2192767718@qq.com

以下以QQ邮箱服务器为例:

telnet smtp.qq.com 25
220 newxmesmtplogicsvrsza10-0.qq.com XMail Esmtp QQ Mail Server.
helo qq.com
250-newxmesmtplogicsvrsza10-0.qq.com-11.137.201.48-22340307
250-SIZE 73400320
250 OK
auth login
334 VXNlcm5hbWU6
MjE5Mjc2NzcxOEBxcS5jb20=
334 UGFzc3dvcmQ6
bWZkdnBhZnNsbHFxZWJkag==
235 Authentication successful
mail from: <[email protected]>

rcpt to: <[email protected]>

data
From:[email protected]

To:[email protected]
Do one thing at a time,
and do well.
.

查看所有账户:
sasldblistusers2

删除
saslpasswd2 -d -u ganxy03.cn root

新建
saslpasswd2 -c -p test