Proxmox 配置外部SMTP发送邮件
proxmox 自带的邮件服务虽然也能发, 不过经常进QQ的垃圾箱. 想想还是配置成QQ的SMTP好了, 稳定点, 别警告邮件都收不到.
安装依赖
apt install -y libsasl2-modules
删除以前配置的aliases
sed '/root:.*/d' /etc/aliases -i
mailname
echo "pve.local" > /etc/mailname
echo "[email protected] [email protected]" > /etc/postfix/generic
配置SMTP服务器, 账号:密码
echo "smtp.qq.com [email protected]:password" > /etc/postfix/sasl_passwd
创建数据库, 设置权限
postmap /etc/postfix/sasl_passwd
postmap /etc/postfix/generic
chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
修改配置文件
$ vim /etc/postfix/main.cf
, 在结尾加上配置
relayhost = smtp.qq.com:465
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sender_dependent_authentication = yes
smtp_generic_maps = hash:/etc/postfix/generic
smtp_use_tls = yes
smtp_tls_wrappermode = yes
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
重启服务
service postfix restart
测试
echo "test mail" | mail -s "proxmox" [email protected]