失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > LINUX邮件收发

LINUX邮件收发

时间:2021-12-08 06:56:28

相关推荐

LINUX邮件收发

1.一般邮件收发

启动服务

[root@kittod ~]# systemctl restart postfix

修改配置

vim /etc/postfix/main.cf

修改如下行

94myhostname =

102 mydomain = #本地域名称

118 myorigin = $mydomain

132 inet_interfaces = all

183 mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

283 mynetworks = 192.168.171.0/24, 127.0.0.0/8 #改为本地网段192.168.171.0

发送邮件
[root@kittod ~]# mail redhat@ Subject: test02 这是测试内容 EOT 注:ctrl+d退出写入

2.群发邮件

/etc/aliases 是别名数据库

vim /etc/aliases

在文件末尾添加

qunfa : xixi,maomao,zhangsan #发送给qunfa,xixi,maomao,zhangsan也会受到

xixi:xixi,maomao #xixi能收到的邮件 maomao也能收到

发送邮件

[root@kittod ~]# mail qunfa Subject: test 这是测试内容 EOT

3.加密邮件收发

在/etc/postfix/下面进行操作

[root@haha ~]# cd /etc/postfix/ [root@haha postfix]# openssl req -new -x509 -nodes -out smtpd.pem -keyout smtpd.pem -days 3650
配置文件/etcpostfix/main.cf
#添加到末尾 smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_key_file = /etc/postfix/smtpd.pem smtpd_tls_cert_file = /etc/postfix/smtpd.pem smtpd_tls_CAfile = /etc/postfix/smtpd.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom
修改文件/etc/postfix/master.cf
29 smtps inet n - n - - smtpd 30 # -o syslog_name=postfix/smtps 31 -o smtpd_tls_wrappermode=yes 32 -o smtpd_sasl_auth_enable=yes

重启服务

[root@haha postfix]# systemctl restart postfix [root@haha postfix]# systemctl restart saslauthd [root@haha postfix]# systemctl restart dovecot

4.虚拟别名域

配置文件/etcpostfix/main.cf

virtual_alias_domains = , virtual_alias_maps = hash:/etc/postfix/virtual #添加到末尾
修改虚拟别名域文件/etc/postfix/virtual
@@ @ @ 123@ maomao,xixi 234@ doudou@,xiaodou@
重新生成虚拟别名域数据库
[root@mail ~]# postmap /etc/postfix/virtual
重新加载虚拟别名域数据文件
[root@mail ~]# systemctl reload postfix

5.启用用户认证收发实验

安装相关软件
[root@kittod ~]# dnf install cyrus-sasl dovecot *sasl* -y

配置文件/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

修改/etc/dovecot/dovecot.conf

25 protocols = imap pop3 lmtp 50 login_trusted_networks = 192.168.226.0/24
修改/etc/dovecot/conf.d/10-mail.conf文件
32 mail_location = mbox:~/mail:INBOX=/var/mail/%u

重启服务

[root@haha postfix]# systemctl restart postfix [root@haha postfix]# systemctl restart saslauthd [root@haha postfix]# systemctl restart dovecot

如果觉得《LINUX邮件收发》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。