1.配置 linux5 为 mail 服务器,安装 postfix 和 dovecot。 2.仅支持 smtps 和 pop3s 连接。 3.创建用户 mail1 和 mail2,向 all@skills.com 发送的邮件,每个用户都会收到。 4.使用 s-nail 在本机进行测试。

- 安装相关软件包
yum install -y postfix* dovecot* s-nail
|
/etc/postfix/master.cf
vim /etc/postfix/master.cf
16 #tlsproxy unix - - n - 0 tlsproxy 17 submission inet n - n - - smtpd 18 -o syslog_name=postfix/submission 19 -o smtpd_tls_security_level=encrypt 20 -o smtpd_sasl_auth_enable=yes 21 -o smtpd_tls_auth_only=yes 22 # -o smtpd_reject_unlisted_recipient=no 23 # -o smtpd_client_restrictions=$mua_client_restrictions 24 # -o smtpd_helo_restrictions=$mua_helo_restrictions 25 # -o smtpd_sender_restrictions=$mua_sender_restrictions 26 # -o smtpd_recipient_restrictions= 27 -o smtpd_relay_restrictions=permit_sasl_authenticated,reject 28 # -o milter_macro_daemon_name=ORIGINATING 29 smtps inet n - n - - smtpd
|
/etc/postfix/mian.cf
95 myhostname = linux5.skills.com 102 mydomain = skills.com 118 myorigin = $mydomain 132 inet_interfaces = all 138 inet_protocols = all
183 #mydestination = $myhostname, localhost.$mydomain, localhost 184 #mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain 185 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, 186 mail.$mydomain, www.$mydomain, ftp.$mydomain
270 mynetworks_style = host 282 mynetworks = 10.10.120.0/24
708 smtpd_tls_cert_file = /etc/ssl/skills.crt 714 smtpd_tls_key_file = /etc/ssl/skills.key 730 smtp_tls_CAfile = /etc/ssl/cacert.pem
|
/etc/dovecot/conf.d/
[root@linux5 conf.d]# vim 10-auth.conf 10 disable_plaintext_auth = yes [root@linux5 conf.d]# vim 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 [root@linux5 conf.d]# vim 10-ssl.conf 14 ssl_cert = </etc/ssl/skills.crt 15 ssl_key = </etc/ssl/skills.key
|
- 将Linux1的证书导入到/etc/ssl中
[root@linux1 ~]# scp /etc/pki/CA/skills.* linux5.skills.com:/etc/ssl skills.crt 100% 4401 3.1MB/s 00:00 skills.csr 100% 1005 829.2KB/s 00:00 skills.key 100% 1704 1.3MB/s 00:00 skills.pfx 100% 2691 3.0MB/s 00:00 [root@linux1 ~]# scp /etc/pki/CA/cacert.* linux5.skills.com:/etc/ssl cacert.pem
|
- 添加别名
[root@linux5 conf.d]# vim /etc/aliases 91 all: mail1,mail2 [root@linux5 conf.d]# newaliases
|
- 添加用户
useradd mail1 useradd mail2
|
- 重启服务
[root@linux5 conf.d]# systemctl restart dovecot postfix
|
- 发送邮件给all 查看mail1 mail2邮箱
[root@linux5 conf.d]# echo "Hello"|mail -s "Welcome" all@skills.com [root@linux5 conf.d]# mail -u mail1 s-nail version v14.9.22. Type `?' for help /var/spool/mail/mail1: 1 message 1 new ▸N 1 root 2024-06-07 09:54 15/444 "Welcome " & 1 [-- Message 1 -- 15 lines, 444 bytes --]: Date: Fri, 07 Jun 2024 09:54:28 +0800 To: all@skills.com Subject: Welcome Message-Id: <20240607015428.6ED2DBE67A@linux5.skills.com> From: root <root@skills.com>
Hello
& quit Held 1 message in /var/spool/mail/mail1 [root@linux5 conf.d]# mail -u mail2 s-nail version v14.9.22. Type `?' for help /var/spool/mail/mail2: 1 message 1 new ▸N 1 root 2024-06-07 09:54 15/444 "Welcome " & 1 [-- Message 1 -- 15 lines, 444 bytes --]: Date: Fri, 07 Jun 2024 09:54:28 +0800 To: all@skills.com Subject: Welcome Message-Id: <20240607015428.6ED2DBE67A@linux5.skills.com> From: root <root@skills.com>
Hello
|