centos搭建邮件服务教程(亲测有效)

系统环境:centos7.8 x86-64

安装 postfix dovecot

 yum install -y postfix dovecot

编辑配置文件

vi /etc/postfix/main.cf

要修改的地方

75行 myhostname = mail.ydqh-tj.com.cn 这里换成自己的域名
83行 mydomain = ydqh-tj.com.cn 换成自己的域名
99行 myorigin = $mydomain
116行 inet_interfaces = all
119行 inet_protocols =ipv4
164行 mydestination = m y h o s t n a m e , l o c a l h o s t . myhostname, localhost. myhostname,localhost.mydomain, localhost,$mydomain
264行 mynetworks = 168.100.189.0/28, 127.0.0.0/8
419行 home_mailbox = Maildir/
572行 smtpd_banner = $myhostname ESMTP $mail_name
在最后加上一下内容

message_size_limit = 10485760
mailbox_size_limit = 1073741824
# for SMTP-Auth
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject

编辑配置文件

 vi /etc/dovecot/dovecot.conf

需要修改的地方
24行 protocols = imap pop3 lmtp
30行 listen = *

编辑配置文件

vi /etc/dovecot/conf.d/10-auth.conf

需要修改的地方
10行 disable_plaintext_auth = no
100行 auth_mechanisms = plain login

编辑配置文件

vi /etc/dovecot/conf.d/10-master.conf

需要修改的地方
88-90行
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}

编辑配置文件

vi /etc/dovecot/conf.d/10-ssl.conf

需要将第8行修改成 ssl = no

编辑配置文件

vi /etc/dovecot/conf.d/10-mail.conf

需要将第24行修改成 mail_location = maildir:~/Maildir

重启postfix dovecot

systemctl restart postfix || systemctl enable postfix
systemctl restart dovecot || systemctl enable dovecot

添加邮箱用户

useradd hello
passwd  hello #这里设置密码要复杂一些至少8位

需要搭建邮件服务可以扫码交流
在这里插入图片描述

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
搭建邮件服务器需要多个组件的配合,包括MTA(Mail Transfer Agent)、MUA(Mail User Agent)、MDA(Mail Delivery Agent)、邮件协议等,以下是在 CentOS 7 上搭建邮件服务器的一个基本步骤: 1. 安装必要的软件包: ``` yum install postfix dovecot firewalld ``` 2. 配置 Postfix 编辑 `/etc/postfix/main.cf` 文件,修改以下选项: ``` myhostname = yourdomain.com # 将 yourdomain.com 替换为你的域名 mydomain = yourdomain.com myorigin = $mydomain inet_interfaces = all mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mynetworks = 127.0.0.1/32 ``` 3. 配置 Dovecot 编辑 `/etc/dovecot/dovecot.conf` 文件,修改以下选项: ``` protocols = imap pop3 lmtp listen = * disable_plaintext_auth = no mail_location = maildir:/var/mail/vhosts/%d/%n userdb { driver = passwd } passdb { driver = shadow } ``` 4. 创建用户和邮箱 ``` useradd -m -s /bin/bash username passwd username ``` 然后在 `/etc/postfix/virtual` 文件中添加以下行: ``` username@yourdomain.com username ``` 5. 启动服务 ``` systemctl start postfix dovecot firewalld systemctl enable postfix dovecot firewalld ``` 6. 配置防火墙 如果你使用了 firewalld 防火墙,那么需要在防火墙中开启相关端口: ``` firewall-cmd --add-port=25/tcp --permanent firewall-cmd --add-port=143/tcp --permanent firewall-cmd --add-port=993/tcp --permanent firewall-cmd --reload ``` 以上就是一个基本的邮件服务器搭建过程,根据你的需求还需要进一步配置,比如 SSL 证书、反垃圾邮件等等。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值