本文将详细介绍如何在 CentOS 7 系统上安装和配置 Postfix 邮件服务器,这是一种流行的开源邮件传输代理(MTA)。我们将通过设置 Postfix 和 Dovecot 来实现邮件发送和接收功能。
sudo yum install postfix dovecot cyrus-sasl-plain
sudo vi /etc/postfix/main.cf
myhostname = mail.example.com
mydomain = example.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
mta_sts_policy = enforce
注释:
sudo systemctl restart postfix
sudo systemctl enable postfix
Dovecot 用于处理邮件的接收(IMAP/POP3)
sudo vi /etc/dovecot/dovecot.conf
disable_plaintext_auth = no
mail_privileged_group = mail
mail_location = maildir:~/Maildir
userdb {
driver = passwd
}
passdb {
args = %s
driver = pam
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
}
sudo systemctl restart dovecot
sudo systemctl enable dovecot
echo "Test email body" | mail -s "Test Email Subject" user@example.com
mutt
希望这篇文章对你有所帮助。如有任何问题或疑问,请在评论区留言。