邮件服务器

搭建邮件服务器,在foxmail上使用wukong@ceshi.com给wuneng@ceshi.com用户发一封邮件,内容为biechile。

第一步

搭建邮件服务

[root@localhost ~]# yum install -y postfix                                    # 装包
[root@localhost ~]# vim /etc/postfix/main.cf                                  # 编辑配置文件
myhostname = mail.ceshi.com                                                   # 指定主机名
mydomain = ceshi.com                                                          # 指定域名
myorigin = $mydomain                                                          # 指定发邮件所显示的域名
inet_interfaces = all                                                         # 指定监听端口
inet_protocols = all                                                          # 指定网络协议
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain        # 指定别人给你发邮件应该写什么主机名
mynetworks = 192.168.168.0/24, 127.0.0.0/8                                    # 指定信任端口

第二步

创建用户 wukong 和 wuneng 并设置密码

[root@localhost ~]# yum install dovecot                                       # 装包
[root@localhost ~]# vim /etc/dovecot/dovecot.conf                             # 编辑配置文件
protocols = imap pop3 lmtp submission                                         # 使用协议
login_trusted_networks = 192.168.168.0/24                                     # 设置允许登录的 ip 段
[root@localhost ~]# vim /etc/dovecot/conf.d/10-mail.conf                      # 编辑配置文件
mail_location = mbox:~/mail:INBOX=/var/mail/%u                                # 用户邮件所在地址
[root@localhost ~]# yum install -y cyrus-sasl                                 # 编写配置文件
broken_sasl_auth_clients = yes                                                # 启用 sasl 对客户端进行认证
smtpd_sasl_auth_enable = yes                                                  # 启用 sasl 认证
smtpd_sasl_security_options = noanonymous                                     # 禁用匿名用户
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination      # 定义收件人限定
[root@localhost ~]# systemctl restart postfix.service                         # 重启服务
[root@localhost ~]# systemctl restart dovecot                                 # 重复服务
[root@localhost ~]# systemctl restart saslauthd.service                       # 重启服务

第三步

下载并安装 foxmail 进行测试
如果不能接受邮件就修改权限

[root@localhost mail]# chmod 0600 /var/mail/*                                 # 修改权限
原文地址:https://www.cnblogs.com/li-qing/p/14082001.html