14.Linux Postfix 邮件服务器

发布: (2026年3月15日 GMT+8 22:19)
3 分钟阅读
原文: Dev.to

Source: Dev.to

实验信息

xFusionCorp Industries 计划在 Stork DC 部署一台通用邮件服务器。经过多次会议和建议后,他们决定使用 Postfix 作为邮件传输代理,使用 Dovecot 作为 IMAP/POP3 服务器。任务如下:

  1. 在 Stork DC 邮件服务器上安装并配置 Postfix。
  2. 创建邮箱账户 anita@stratos.xfusioncorp.com,密码为 LQfKeWWxWD
  3. 将其邮件目录设置为 /home/anita/Maildir
  4. 在同一台服务器上安装并配置 Dovecot。

实验解答

第 1 部分:实验逐步指南

目标

在邮件服务器 (stmail01) 上:

  • 安装 Postfix
  • 创建邮件用户 anita
  • 配置邮箱位置
  • 安装并配置 Dovecot

服务器访问

# 1️⃣ 登录跳转主机
ssh thor@jump_host.stratos.xfusioncorp.com
# Password: mjolnir123

# 2️⃣ 连接邮件服务器
ssh groot@stmail01
# Password: Gr00T123

# 3️⃣ 切换到 root
sudo -i

安装 Postfix

yum install -y postfix
systemctl start postfix
systemctl enable postfix

创建用户 anita

useradd anita
passwd anita
# Enter password: LQfKeWWxWD

创建邮件目录

mkdir -p /home/anita/Maildir
chown -R anita:anita /home/anita/Maildir

配置 Postfix 邮箱位置

编辑 /etc/postfix/main.cf 并添加以下行:

home_mailbox = Maildir/

保存并退出,然后重启 Postfix:

systemctl restart postfix

安装 Dovecot

yum install -y dovecot

配置 Dovecot 邮件位置

编辑 /etc/dovecot/conf.d/10-mail.conf 并设置:

mail_location = maildir:~/Maildir

保存并退出。

启动并启用 Dovecot

systemctl start dovecot
systemctl enable dovecot

验证服务

systemctl status postfix
systemctl status dovecot

两者都应显示 active (running)

第 2 部分:简明说明(适合初学者)

本实验构建的内容

你正在搭建一个基本的 Linux 邮件服务器,包含两个主要组件:

组件用途
Postfix邮件传输代理(接收并投递邮件)
DovecotIMAP/POP3 服务器(让用户读取邮件)

邮件流示例

用户发送邮件 → Postfix 投递到邮箱 → Dovecot 通过 IMAP/POP3 提供访问

邮件存储格式

格式描述
Maildir首选,因为它更快、更安全,且更适合并发访问

用户 anita 的邮箱位于:

/home/anita/Maildir

Postfix 将收到的邮件存放在 Maildir/ 文件夹中(例如 /home/anita/Maildir/new),Dovecot 则从该位置读取邮件,为用户提供服务。

0 浏览
Back to Blog

相关文章

阅读更多 »