1. 前期准备:

主机:CentOS release 7.6.1810 (Core)     #安装时选择邮件服务器

IP:192.168.71.108   #示例

本地yum源 #因为是内网,所以建议用镜像搭建本地yum源

2. 基础环境配置

关闭selinux:

sed –I ‘s/enforcing/disabled/g’  /etc/selinux/config

防火墙等配置:

firewall-cmd –add-port=’110/tcp’ –permanent

firewall-cmd –add-port=’25/tcp’ –permanent

或直接关闭防火墙,因为是内网,也不会有安全问题

systemctl start firewalld.service

主机名配置:

重启系统以使上述配置生效

shutdown  -r now

3. Postfix安装与配置

3.1. 安装postfix

因为安装centos时选择的是邮件系统,所以检查是否自带postfix服务,如果没带则可通过本地yum源安装:yum -y insatll postfix --nogpgcheck

3.2. 配置postfix

[root@mail ~]# vim /etc/postfix/main.cf

  • myhostname =mail.yzp.com  #定义主机名
  • mydomain =yzp.com   #定义域名
  • myorigin =$mydomain  #定义组织域
  • 我们需要在mydestination的值后面添加 $mydomain ,
  • 如果不添加的话,收件人的地址会有问题,如果添加后,用户发送邮件直接会是xx@yzp.com
  • 取消注释 #local_recipient_maps =

3.3. 启动和检查postfix

[root@mail ~]# systemctl start postfix.service

[root@mail ~]# systemctl enable postfix.service

[root@mail ~]# netstat -nltp

4. dovecot安装与配置

4.1. 安装dovecot

[root@mail ~]#  yum -y  install dovecot --nogpgcheck

4.2. 配置dovecot

接下来我们查看dovecot的默认配置文件

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

我们看见以下include可以包含的配置文件路径,在该路径下的*.conf文件都会生效

4.2.1. vim /etc/dovecot/dovecot.conf启用协议以下协议及监听

protocols = imap pop3 lmtp

#启用端口监听

listen = *,::

4.2.2. vim /etc/dovecot/conf.d/10-auth.conf设置如下参数

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

disable_plaintext_auth = no

auth_mechanisms = plain login

!include auth-system.conf.ext

4.2.3. vim /etc/dovecot/conf.d/10-ssl.conf禁用ssl认证

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

ssl = no

4.2.4. vim /etc/dovecot/conf.d/10-logging.conf启用dovecot的日志

vim /etc/dovecot/conf.d/10-logging.conf

添加

info_log_path = /var/log/dovecot_info.log

debug_log_path = /var/log/dovecot_debug.log

4.3. 启动和检查dovecot

[root@mail ~]# systemctl start dovecot.service

[root@mail ~]# systemctl enable dovecot.service

[root@mail ~]# netstat -nltp | grep dovecot

5. 创建测试账户与测试邮件收发通信

5.1. 创建两个测试账户

[root@mail ~]# useradd test1

[root@mail ~]# passwd test1

[root@mail ~]# useradd test2

[root@mail ~]# passwd test2

5.2. 测试110端口:收邮件端口

[root@mail ~]# telnet 192.168.71.108 110

Trying 192.168.71.108...

Connected to 192.168.71.108.

Escape character is '^]'.

+OK [XCLIENT] Dovecot ready.

user test1

+OK

pass 111111

+OK Logged in.

-ERR [SYS/PERM] Permission denied

Connection closed by foreign host.

我们查看log

[root@mail ~]# cd /var/log/

[root@mail log]# tailf maillog

我们切换到刚才的用户:

[test1@mail ~]$ su - test1

密码:

[test2@mail ~]$  mkdir -p ~/mail/.imap/INBOX

[test1@mail ~]$ su - test2

密码:

[test2@mail ~]$  mkdir -p ~/mail/.imap/INBOX

再次测试110端口,发现测试通过了

[root@mail ~]# telnet 192.168.71.108 110

Trying 192.168.71.108...

Connected to 192.168.71.108.

Escape character is '^]'.

+OK [XCLIENT] Dovecot ready.

user test1

+OK

pass 111111

+OK Logged in.

quit

+OK Logging out.

Connection closed by foreign host.

5.3. 测试25端口:发邮件端口

[root@mail ~]# telnet 192.168.71.108 25

Trying 192.168.71.108...

Connected to 192.168.71.108.

Escape character is '^]'.

220 mail.yzp.com ESMTP unkown

mail from:test1@yzp.com

250 2.1.0 Ok

rcpt to:test2@yzp.com

250 2.1.5 Ok

data

354 End data with <CR><LF>.<CR><LF>

.

250 2.0.0 Ok: queued as 338CE61533C9

quit

221 2.0.0 Bye

Connection closed by foreign host.

5.4. 测试上述查收上述test1发给test2的邮件

6. 同局域网内的windows电脑配置foxmail测试邮件收发

6.1. 配置新建账号

6.2. 互相收发邮件

收发测试通过,至此,环境搭建通过。

7. 检查邮件存储位置

[root@mail postfix]# cat /etc/dovecot/conf.d/10-mail.conf | grep mail_location

# path given in the mail_location setting.

#   mail_location = maildir:~/Maildir

mail_location = mbox:~/mail:INBOX=/var/mail/%u

#   mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n

#mail_location =

# mail_location, which is also the default for it.

[root@mail postfix]# cd /var/mail/

Centos7+Postfix+Dovecot实现内网邮件收发的更多相关文章

  1. #centos7 创建内网yum源 OpenStack源部署

    #centos7 创建内网yum源#centos7 自动化安装 本地 内网 web源创建.更新 createrepo http OpenStack源部署 Elven原创 http://www.cnbl ...

  2. centos7内网源站建设

    centos7内网源站建设 1.部署环境: 系统:Centos7 x86_64 应用服务:nginx.createrepo.reposync 镜像源:https://mirrors.aliyun.co ...

  3. 企业内部在centos7.2系统中必杀技NTP时间服务器及内网服务器时间同步(windows和linux客户端同步)

    网络时间协议NTP(Network Time Protocol)是用于互联网中时间同步的标准互联网协议.NTP的用途是把计算机的时间同步到某些时间标准.目前采用的时间标准是世界协调时UTC(Unive ...

  4. 云端搭建内网局域网+NAT冗余上网:vps-centos6.10 +pptp client +2个ros 实现默认走pptp上网,万一pptp断了,走另外一个ros路由+centos7补充了下

    介绍下环境: 1.ROS1也是PPTP SERVER,IP为172.16.22.3/24,pptp pool为172.16.23.0/24,pptp的默认帐号是111,密码是123 2.ROS2的IP ...

  5. centos7 virtualbox使用internal network 内网模式

    1)打开对应虚拟机的Settings,点开Network, 2)Adapter1如果已经选了挂到Bridged Adapter,则点开Adapter2, 3)选择挂到 Internal Network ...

  6. Centos7.2内网环境安装MySQL5.7.24

    1.配置本地yum源 内网环境,首先需要配置本地yum源,以解决MySQL的依赖安装,具体参考该文:点击打开 2.查看服务器环境 uname -a 3.去官网下载MySQL安装包 MySQL官网网址: ...

  7. Docker 18.03 Centos7.6 安装 内网

    首先访问https://download.docker.com/linux/centos/7/x86_64/stable/Packages/获取对应版本的rpm包docker包docker-ce-18 ...

  8. centos7下配置iptables实现外网访问内网服务器

    说明:Centos 7 默认的防火墙是 firewall,安装iptables之前需关闭Firewall 外网机器:外网ip:120.25.71.183内网ip:10.1.1.23 内网机器:内网ip ...

  9. centos7下使用n grok编译服务端和客户端穿透内网

    (发现博客园会屏蔽一些标题中的关键词,比如ngrok.内网穿透,原因不知,所以改了标题才能正常访问,) 有时候想在自己电脑.路由器或者树莓派上搭建一些web.vpn等服务让自己用,但是自己的电脑一般没 ...

随机推荐

  1. Java学习之随堂笔记系列——day02

    昨天内容回顾1.安装jdk和配置环境变量 配置JAVA_HOME和path,只要配置成功之后就可以直接使用java和javac命令.2.HelloWorld案例3.java的基础语法 注释:给程序的解 ...

  2. P4606-[SDOI2018]战略游戏【圆方树,虚树】

    正题 题目链接:https://www.luogu.com.cn/problem/P4606 题目大意 给出\(n\)个点\(m\)条边的一张图,\(q\)次询问给出一个点集,询问有多少个点割掉后可以 ...

  3. 一个Electron的设计缺陷及应对方案

    当你想实现阻止Electron窗口关闭,并弹出询问对话框,提示用户:"文章尚未保存,是否要关闭窗口"这类业务时,那么你99%会碰到这个BUG: https://github.com ...

  4. NOIP模拟69

    T1 石子游戏 大坑未补 T2 大鱼吃小鱼 解题思路 set+桶可以得到 60pts (code) 线段树上二分每一次优先递归右区间从右区间贪心选择,并且记录下更改过的值,在处理完答案之后再复原回去. ...

  5. Codeforces Round #747 (Div. 2)

    比赛地址 A(水题) 题目链接 题目: 给出指定\(n\),求解出一段区间\([l,r]\)使得\(\sum\limits_{i=l}^ri=n\) 解析: 从点0,1两点作为起点分别向左右延伸长度, ...

  6. [源码解析] PyTorch 流水线并行实现 (6)--并行计算

    [源码解析] PyTorch 流水线并行实现 (6)--并行计算 目录 [源码解析] PyTorch 流水线并行实现 (6)--并行计算 0x00 摘要 0x01 总体架构 1.1 使用 1.2 前向 ...

  7. bzoj2037 Sue的小球(区间dp,考虑到对未来的贡献)

    ​​​​​​​​​​​​​​大致意思就是现在你要不断的奔跑到不同的地点去接球,每一秒可以移动一个单位长度,而你接到一个球的动作是瞬间的,收益是y[i]-t*v[i] 然后呢,要求分数最高. 起初看这个 ...

  8. 试题 历届试题 核桃的数量 java题解

    资源限制 时间限制:1.0s   内存限制:256.0MB 问题描述 小张是软件项目经理,他带领3个开发组.工期紧,今天都在加班呢.为鼓舞士气,小张打算给每个组发一袋核桃(据传言能补脑).他的要求是: ...

  9. selenium去特征

    code from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_ex ...

  10. 热身训练1 ping ping ping

    点此进入 题意: 一棵树,n+1 个节点,以0号节点为根,给出端点(a,b),节点a到节点b的路径上,至少有一个点是"坏掉的",求"坏掉的点"最少 分析: St ...