linux环境下基于postfix服务启用用户认证邮件收发
1.安装相关软件
[root@kittod ~]# dnf install cyrus-sasl dovecot *sasl* -y
[root@kittod ~]# dnf install postfix mailx -y
2.postfix主配置文件追加如下内容
[root@kittod ~]# vim /etc/postfix/main.cf
#启用SASL对客户端进行认证
broken_sasl_auth_clients = yes
#启用SASL认证
smtpd_sasl_auth_enable = yes
#禁用匿名用户
smtpd_sasl_security_options = noanonymous
#定义收件人限定
smtpd_recipient_restrictions =
permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
3.修改dovecot配置文件
[root@kittod ~]# vim /etc/dovecot/dovecot.conf
23 # Protocols we want to be serving.
24 #protocols = imap pop3 lmtp submission
25 protocols = imap pop3 lmtp
45 # Space separated list of trusted network ranges. Connections from these
46 # IPs are allowed to override their IP addresses and ports (for logging and
47 # for authentication checks). disable_plaintext_auth is also ignored for
48 # these networks. Typically you'd specify your IMAP proxy servers here.
49 #login_trusted_networks =
50 login_trusted_networks = 192.168.226.0/24
5.修改10-mail.conf配置文件
[root@kittod ~]# vim /etc/dovecot/conf.d/10-mail.conf
24 # mail_location = maildir:~/Maildir
25 # mail_location = mbox:~/mail:INBOX=/var/mail/%u
26 # mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
27 #
28 # <doc/wiki/MailLocation.txt>
29 #
30 #mail_location =
31
32 mail_location = mbox:~/mail:INBOX=/var/mail/%u
6.重启以下服务
[root@kittod ~]# systemctl restart postfix
[root@kittod ~]# systemctl restart dovecot
[root@kittod ~]# systemctl restart saslauthd
7. 查看服务状态
[root@kittod ~]# systemctl status postfix
● postfix.service - Postfix Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor
preset: disabled)
Active: active (running) (thawing) since Mon 2021-10-25 17:52:47 CST; 23min
ago
Process: 8096 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
Process: 8115 ExecStart=/usr/sbin/postfix start (code=exited,
status=0/SUCCESS)
Process: 8113 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited,
status=0/SUCCESS)
Process: 8110 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited,
status=0/SUCCESS)
Main PID: 8182 (master)
Tasks: 3 (limit: 49294)
Memory: 7.2M
CGroup: /system.slice/postfix.service
├─8182 /usr/libexec/postfix/master -w
├─8183 pickup -l -t unix -u
└─8184 qmgr -l -t unix -u
Oct 25 17:53:03 kittod postfix/qmgr[8184]: 6166BB573E: from=<root@haha.com>,
size=423, nrcpt=1 (queue active)
Oct 25 17:53:03 kittod postfix/local[8190]: 6166BB573E: to=<redhat@haha.com>,
relay=local, delay=0.03, delays=>
Oct 25 17:53:03 kittod postfix/qmgr[8184]: 6166BB573E: removed
Oct 25 17:57:24 kittod postfix/pickup[8183]: 0B455B573E: uid=0 from=<root>
Oct 25 17:57:24 kittod postfix/cleanup[8245]: 0B455B573E: message-id=
<20211025095724.0B455B573E@mail.haha.com>
Oct 25 17:57:24 kittod postfix/qmgr[8184]: 0B455B573E: from=<root@haha.com>,
size=426, nrcpt=1 (queue active)
Oct 25 17:57:24 kittod postfix/local[8247]: 0B455B573E: to=<maomao@haha.com>,
orig_to=<workgroup@haha.com>, re>
Oct 25 17:57:24 kittod postfix/local[8247]: 0B455B573E: to=<xixi@haha.com>,
orig_to=<workgroup@haha.com>, rela>
Oct 25 17:57:24 kittod postfix/local[8247]: 0B455B573E: to=<redhat@haha.com>,
orig_to=<workgroup@haha.com>, re>
Oct 25 17:57:24 kittod postfix/qmgr[8184]: 0B455B573E: removed
[root@kittod ~]# systemctl status dovecot
● dovecot.service - Dovecot IMAP/POP3 email server
Loaded: loaded (/usr/lib/systemd/system/dovecot.service; disabled; vendor
preset: disabled)
Active: active (running) (thawing) since Sun 2021-10-24 15:38:03 CST; 1 day
2h ago
Docs: man:dovecot(1)
http://wiki2.dovecot.org/
Process: 6702 ExecStop=/usr/bin/doveadm stop (code=exited, status=0/SUCCESS)
Process: 6706 ExecStartPre=/usr/libexec/dovecot/prestartscript (code=exited,
status=0/SUCCESS)
Main PID: 6713 (dovecot)
Tasks: 5 (limit: 49294)
Memory: 9.5M
CGroup: /system.slice/dovecot.service
├─6713 /usr/sbin/dovecot -F
├─6714 dovecot/anvil
├─6715 dovecot/log
├─6716 dovecot/config
└─6718 dovecot/stats
Oct 25 18:13:04 kittod dovecot[6715]: pop3-login: Login: user=<redhat>,
method=PLAIN, rip=192.168.226.1, lip=1>
Oct 25 18:13:04 kittod dovecot[6715]: pop3(redhat)<8430><DlRNmyrPucDAqOIB>:
Disconnected: Logged out top=0/0, >
Oct 25 18:14:02 kittod dovecot[6715]: pop3-login: Login: user=<xixi>,
method=PLAIN, rip=192.168.226.1, lip=192>
Oct 25 18:14:02 kittod dovecot[6715]: pop3(xixi)<8435><12HGnirP28DAqOIB>:
Disconnected: Logged out top=0/0, re>
Oct 25 18:14:14 kittod dovecot[6715]: pop3-login: Login: user=<maomao>,
method=PLAIN, rip=192.168.226.1, lip=1>
Oct 25 18:14:14 kittod dovecot[6715]: pop3(maomao)<8440><5UFynyrP4sDAqOIB>:
Disconnected: Logged out top=0/0, >
Oct 25 18:14:15 kittod dovecot[6715]: pop3-login: Login: user=<xixi>,
method=PLAIN, rip=192.168.226.1, lip=192>
Oct 25 18:14:15 kittod dovecot[6715]: pop3-login: Login: user=<maomao>,
method=PLAIN, rip=192.168.226.1, lip=1>
[root@kittod ~]# systemctl status saslauthd
● saslauthd.service - SASL authentication daemon.
Loaded: loaded (/usr/lib/systemd/system/saslauthd.service; disabled; vendor
preset: disabled)
Active: active (running) (thawing) since Sun 2021-10-24 15:37:56 CST; 1 day
2h ago
Process: 6694 ExecStart=/usr/sbin/saslauthd -m $SOCKETDIR -a $MECH $FLAGS
(code=exited, status=0/SUCCESS)
Main PID: 6695 (saslauthd)
Tasks: 5 (limit: 49294)
Memory: 3.9M
CGroup: /system.slice/saslauthd.service
├─6695 /usr/sbin/saslauthd -m /run/saslauthd -a pam
├─6696 /usr/sbin/saslauthd -m /run/saslauthd -a pam
├─6697 /usr/sbin/saslauthd -m /run/saslauthd -a pam
├─6698 /usr/sbin/saslauthd -m /run/saslauthd -a pam
└─6699 /usr/sbin/saslauthd -m /run/saslauthd -a pam
Oct 24 15:37:56 kittod systemd[1]: Starting SASL authentication daemon....
Oct 24 15:37:56 kittod saslauthd[6695]: : master pid is: 6695
Oct 24 15:37:56 kittod systemd[1]: Started SASL authentication daemon..
启动foxmail客户端,选择【其他邮箱】添加邮箱,接
点击【手动设置】
**注:**安装foxmail客户端
下载链接 https://www.foxmail.com