目录
遇权不绝就转root
sudo -i
更新系统
apt update
# 网不好的人别敲了,这玩意太久了
apt upgrade -y
安装 Postfix
apt install -y postfix
假设我的公司域名是 wmcode.com
那么 我待会输入的邮件服务器主机名则是 mail.wmcode.com
配置 Postfix
vi /etc/postfix/main.cf
配置前
home_mailbox = Maildir/
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous,noplaintext
smtpd_sasl_tls_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtp_tls_security_level = may
smtpd_tls_security_level = may
smtp_tls_note_starttls_offer = yes
smtpd_tls_CApath = /etc/ssl/certs
smtpd_tls_cert_file = /etc/ssl/certs/server.crt
smtpd_tls_key_file = /etc/ssl/private/server.key
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_auth_only = yes
修改后
重启 Postfix
systemctl restart postfix
安装 Dovecot
apt install -y dovecot-core dovecot-imapd dovecot-lmtpd dovecot-mysql
配置 Dovecot
vi /etc/dovecot/dovecot.conf
编辑 Dovecot 的 IMAP 配置文件
vi /etc/dovecot/conf.d/10-mail.conf
编辑 Dovecot 的用户认证配置文件
vi /etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain login
编辑 Dovecot 的服务配置文件
vi /etc/dovecot/conf.d/10-master.conf
#修改以下内容
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
mode = 0600
user = postfix
group = postfix
}
}
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0660
user = postfix
group = postfix
}
}
重启 Dovecot
systemctl restart dovecot
安装发送邮箱功能
apt install -y mailutils
发送邮件
echo "This is the email body" | mail -s "Test Subject" other_email@outlook.com -r chen@wmcode.com
echo "This is the email body"
:邮件正文内容。mail -s "Test Subject"
:邮件主题。other_email@outlook.com
:收件人邮箱地址。-r chen@wmcode.com
:发件人邮箱地址。
测试
邮件可能在垃圾邮箱里面
* Thanks you *
如果觉得文章内容不错,随手帮忙点个赞、在看、转发一下,如果想第一时间收到推送,也可以给我个星标⭐~谢谢你看我的文章。
*往期推荐 *
银河麒麟 | ubuntu 安装运用 docker 容器,实现容器化部署项目
银河麒麟 | ubuntu 安装zabbix监控设备信息(亲测包对)
只需5步让你轻松导出学习通纯考试题目(JavaScript)
国产操作系统-银河麒麟本地化部署Ollama国产开源的AI大模型Qwen3
Swagger | 手把手带你写自动生成接口文档的爽感(零基础亲测实用)
SpringBoot整合Openfeign接入Kimi Ai!!超简单,居然没多少行代码??(附加兜底教程)
Maven | 站在初学者的角度配置与项目创建(新手必学会)
Spring Ai | 极简代码从零带你一起走进AI项目(中英)
MongoDB | 零基础学习与Springboot整合ODM实现增删改查(附源码)
Openfeign | 只传递城市代码,即可获取该地域实时的天气数据(免费的天气API)
Mongodb | 基于Springboot开发综合社交网络应用的项目案例(中英)
感谢阅读 | 更多内容尽在公棕号 WMCode | CSDN@小Mie不吃饭