CentOS8部署postfix
2024/05/09 15:04 投稿
本文参照centos8电子邮件服务—1.基于Postfix的邮件发送(超级详细)_centos8 启动postfix-CSDN博客配置并记录。感谢原博主2301_77831574的详细和认真,本文仅复现。
本次环境OS:
1.修改主机名并修改/etc/hosts
#hostnamectl set-hostname test.latiao.org
#vim /etc/hosts
2.安装postfix
#yum -y install postfix
#systemctl enable postfix --now
3.安装mailx邮件客户端
#yum -y install mailx
4.配置 Postfix 邮件服务器
#vim /etc/postfix/main.cf
# cat /etc/postfix/main.cf | egrep -v '^$|^#'
compatibility_level = 2
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.test.latiao.org
mydomain = test.latiao.org
myorigin = $mydomain
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
mynetworks = 192.168.137.0/24, 127.0.0.0/8
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix/samples
readme_directory = /usr/share/doc/postfix/README_FILES
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.key
smtpd_tls_security_level = may
smtp_tls_CApath = /etc/pki/tls/certs
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_security_level = may
meta_directory = /etc/postfix
shlib_directory = /usr/lib64/postfix
5.重启
systemctl restart postfix
6.测试postfix
[root@test roundcube]# telnet 0 25
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
220 mail.test.latiao.org ESMTP Postfix
helo main.test.latiao.org # (向服务器表明身份)
250 mail.test.latiao.org
mail from:[email protected] #(设置发件人)
250 2.1.0 Ok
rcpt to:[email protected]
250 2.1.5 Ok
#(设置邮件内容,用data命令编辑邮件内容,以“.”结束)
data
354 End data with <CR><LF>.<CR><LF>
hello world!!!
.
250 2.0.0 Ok: queued as 6C8EF10D74A1
quit #(quit时退出telnet命令)
221 2.0.0 Bye
Connection closed by foreign host.
7.发送完毕。可以去收件箱看看,大概率会进垃圾箱。