搭建内网邮件服务并使用foxmail进行收发

很多场景都需要邮件服务,比如说告警推送。由于绝大多数场景下,内网服务器是不允许访问互联网的(即使通过代理),当然这主要跟信息安全有关。

想用那只能搭建一套内网邮件服务,实现最基本的邮件收发功能。

本文将带你基于centos7搭建一套内网邮件系统。

搭建配置postfix

  1. 配置
$ sudo tee /etc/postfix/main.cf <
  1. 启动
$ systemctl enable postfix --now

安装cyrus-sasl

sasl主要用于邮箱用户名密码认证

  1. 安装sasl
$ yum -y install cyrus-sasl
  1. 配置sasl
$ sudo tee /etc/sysconfig/saslauthd <
  1. 启动sasl
[root@localhost ~]# service saslauthd start
Redirecting to /bin/systemctl start saslauthd.service
[root@localhost ~]# chkconfig saslauthd on
Note: Forwarding request to 'systemctl enable saslauthd.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/saslauthd.service to /usr/lib/systemd/system/saslauthd.service.
  1. 测试sasl
[root@localhost ~]# useradd ilanni &&echo 'ilannimail'| passwd --stdin ilanni
Changing password for user ilanni.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# su - ilanni
[ilanni@localhost ~]$ mkdir -p ~/mail/.imap/INBOX
[ilanni@localhost ~]$ testsaslauthd -u ilanni -p 'ilannimail'
0: OK "Success."
[ilanni@localhost ~]$ exit
[root@localhost ~]# userdel -r ilanni
  1. 测试postfix
$ yum install -y telnet

安装dovecot

  1. 安装
$ yum -y install dovecot dovecot-devel dovecot-mysql pam-devel
  1. 配置
$ sudo tee /etc/dovecot/dovecot.conf <
  1. 启动
$ systemctl enable dovecot --now
  1. 重启postfix
$ systemctl restart postfix
  1. 查看端口监听
[root@localhost ~]# ss -aln|grep 25
tcp    LISTEN     0      100       *:25                    *:*
tcp    LISTEN     0      100    [::]:25                 [::]:*
[root@localhost ~]# ss -aln|grep 110
tcp    LISTEN     0      100       *:110                   *:*
tcp    LISTEN     0      100    [::]:110                [::]:*
[root@localhost ~]# ss -aln|grep 143
tcp    LISTEN     0      100       *:143                   *:*
tcp    LISTEN     0      100    [::]:143                [::]:*
  1. 创建邮件用户
[root@localhost ~]# useradd user1 &&echo '123456'| passwd --stdin user1
Changing password for user user1.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# useradd user2 &&echo '123456'| passwd --stdin user2
Changing password for user user2.
passwd: all authentication tokens updated successfully.
  1. 激活用户
[root@localhost home]# telnet 192.168.1.1 pop3
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
+OK Dovecot ready.
user user1
+OK
pass 123456
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.
[root@localhost home]# ls /home/user1/
.bash_logout   .bash_profile  .bashrc        Maildir/
[root@localhost home]# ls /home/user1/Maildir/
cur  dovecot.index.log  dovecot-uidlist  dovecot-uidvalidity  dovecot-uidvalidity.61c43406  new  tmp
[root@localhost home]# telnet 192.168.1.1 pop3
Trying 192.168.1.1...
Connected to 192.168.1.1.
Escape character is '^]'.
+OK Dovecot ready.
user user2
+OK
pass 123456
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.
[root@localhost home]# ls /home/user2/
.bash_logout   .bash_profile  .bashrc        Maildir/
[root@localhost home]# ls /home/user2/Maildir/
cur  dovecot.index.log  dovecot-uidlist  dovecot-uidvalidity  dovecot-uidvalidity.61c43406  new  tmp

配置foxmail

  1. 配置host解析

C:\Windows\System32\drivers\etc\hosts

添加解析内容(192.168.1.1为邮件服务器IP地址)

192.168.1.1 mail.wl.com
  1. 配置foxmail

配置信息如下

  1. 测试

user1user2互发邮件

  1. 架构说明

你可能感兴趣的:(搭建内网邮件服务并使用foxmail进行收发)