按照别人的教程写的 linux 下 mail服务器 的搭建

本文详细介绍了如何在CentOS 6.9 64位系统上搭建邮件服务器,包括Postfix作为邮件传输代理和Dovecot作为IMAP与POP3邮件服务器的安装与配置步骤。通过编辑main.cf和dovecot.conf等配置文件,实现了邮件的发送、接收以及SMTP认证等功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用于搭建的服务器信息

虚拟机 Centos 6.9 64位

Postfix-2.8.12.tar.gz      Postfix MTA(邮件传输代理)
Dovecot-2.1.8.tar.gz      IMAP 和 POP3 邮件服务器  //没有使用foxmail等客户端测试

以下这2个没使用到(备忘)。

Postfixadmin-2.3.5.tar.gz    采用PHP编写的开源WEB邮箱及域名账号管理工具
Roundcubemail-0.8.1.tar.gz  采用PHP编写的开源IMAP邮件WEB客户端

安装过程

1.安装Postfix

yum -y install postfix

安装完成还需要替换系统自带的sendmail:


 
  1. rpm -e sendmail

  2. 或者

  3. yum remove sendmail

  4.  

修改MTA(默认邮件传输代理)


 
  1. alternatives --config mta

  2.  

然后直接回车即可。

检查一下是不是已经设置成功了。


 
  1. alternatives --display mta

  2.  

第一行可以看到mta的状态。 例如:mat - status is manual.

2.安装Dovecot

yum -y install dovecot

3.配置Postfix

编辑/etc/postfix/main.cf,可以下载下来修改,也可以使用vi进行编辑:

vi /etc/postfix/main.cf

修改如下:

# 75行: 取消注释,设置hostname

myhostname = mail.lomu.me

# 83行: 取消注释,设置域名

mydomain = lomu.me

# 99行: 取消注释

myorigin = $mydomain

# 116行: 修改

inet_interfaces = all

# 119行: 推荐ipv4,如果支持ipv6,则可以为all

inet_protocols = ipv4

# 164行: 添加

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

# 264行: 取消注释,指定内网和本地的IP地址范围

mynetworks = 127.0.0.0/8, 10.0.0.0/24

# 419行: 取消注释,邮件保存目录

home_mailbox = Maildir/

# 571行: 添加

smtpd_banner = $myhostname ESMTP


# 添加到最后

# 规定邮件最大尺寸为10M

message_size_limit = 10485760

# 规定收件箱最大容量为1G

mailbox_size_limit = 1073741824

# SMTP认证

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

改好了之后使用/etc/rc.d/init.d/postfix start开启postfix,使用chkconfig postfix on将postfix开机启动。

 

 

4.配置Dovecot

修改如下:

[root@mail ~]# vi /etc/dovecot/dovecot.conf

# 26行: 如果不使用IPv6,请修改为*

listen = *


[root@mail ~]# vi /etc/dovecot/conf.d/10-auth.conf

# 9行: 取消注释并修改

disable_plaintext_auth = no

# 97行: 添加

auth_mechanisms = plain login


[root@mail ~]# vi /etc/dovecot/conf.d/10-mail.conf

# 30行: 取消注释并添加

mail_location = maildir:~/Maildir


[root@mail ~]# vi /etc/dovecot/conf.d/10-master.conf

# 88-90行: 取消注释并添加

# Postfix smtp验证

unix_listener /var/spool/postfix/private/auth {

mode = 0666

user = postfix

group = postfix

}


[root@mail ~]# /etc/rc.d/init.d/dovecot start

Starting Dovecot Imap: [ OK ]


[root@mail ~]# chkconfig dovecot on

 

 

 

到这里,我们的邮件服务器就已经搭建成功了

 

 

在此 使用了 HOSTS设置了域名解析。没有使用DNS SERVER

vi /etc/hosts

 

IP     域名       主机号

格式

 

测试:

$usersadd admin

$usersadd gamers

mail -s "hello" gamer@域名      //回车后是内容

这里是内容。。。

Ctrl +D 编辑完成邮件内容并发送

EOT  //说明pass

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值