本文主要是介绍【Linux】CentOS 7 安装配置 postfix 邮件服务器随笔,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本文并不是完整配置教程,只是配置过程中零散代码随笔,不成系统
记录配置 PostFix 邮件服务器过程,由于经常用到,会不定时更新完善
yum install -y postfix dovecot cyrus-sasl-plain cyrus-sasl mailx# 设置hostname
hostnamectl set-hostname mail.i7do.com
cat /etc/hostnamevim /etc/hosts //添加下面一行
127.0.0.1 mail.i7do.cn# 检查配置文件
postconf -a
postfix checksystemctl restart postfix.service
systemctl enable postfix.service
修改 main.cf
#修改以下配置
myhostname = mail.i7do.com //邮件服务器的主机名
mydomain = i7do.com //邮件域
myorigin = $mydomain //往外发邮件的邮件域
inet_interfaces = all //监听的网卡
inet_protocols = all
mydestination = $myhostname, $mydomain //服务的对象
home_mailbox = Maildir/ //邮件存放的目录# 规定邮件最大尺寸为10M
message_size_limit = 10485760
# 规定收件箱最大容量为1G
mailbox_size_limit = 1073741824
# SMTP认证
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
mynetworks = 127.0.0.0/8
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination# SSL 加密
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/server.crt
smtpd_tls_key_file = /etc/pki/tls/certs/server.key
smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scachesmtp_tls_CApath = /etc/ssl/certs
smtpd_tls_CApath = /etc/ssl/certs
smtp_tls_security_level = maysmtpd_relay_restrictions = permit_myNetworks,permit_sasl_authenticated,defer_unauth_destination
创建证书:
cat /etc/dovecot/dovecot.pem
cd /etc/pki/tls/misc
./CA -newca
openssl req -new -nodes -keyout mailkey.pem -out mailreg.pem -days 365
rm -f /etc/pki/CA/index.txt
touch /etc/pki/CA/index.txt
openssl ca -out mail_signed_cert.pem -infiles mailreg.pem
vim /etc/pki/tls/openssl.cnfopenssl genrsa -des3 -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl rsa -in server.key -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
openssl x509 -in server.crt -out server.pem -outform PEM
创建用户:
useradd fan -s /sbin/nologin
echo '123123' | passwd --stdin fan
检查进程是否启动:
netstat -anpt | grep dovecot
netstat -anpt | grep postfix
netstat -anpt | grep smtp
netstat -anpt | grep master
测试发送邮件:
yum -y install mailx
echo '这是测试' | mail -s '你好,164' islacker@qq.com
这篇关于【Linux】CentOS 7 安装配置 postfix 邮件服务器随笔的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!