Centos7 使用postfix实现Gmail邮件转发

56次阅读
没有评论

1. Gmail开启SMTP功能

方式自行百度,此处不展示

2. 安装postfix

yum install postfix cyrus-sasl-sql cyrus-sasl-plain cyrus-sasl-lib mailx

3. 配置main.cf文件

vim /etc/postfix/main.cf //编辑main.cf文件
底部添加以下内容

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_security_level = may

4. 新建邮箱认证配置文件

vim /etc/postfix/sasl_passwd
并添加以下内容
[smtp.gmail.com]:587 testss@gmail.com:wixhljacufesesws

前半段为smtp服务器地址及端口,后半部分为你的邮箱地址及密码(SMTP授权码)

修复权限并更新 postfix 配置以使用 sasl_passwd 文件:

chmod 400 /etc/postfix/sasl_passwd 
postmap /etc/postfix/sasl_passwd

重启postfix saslauthd
systemctl restart postfix
systemctl restart saslauthd

5. 邮件测试

echo "Test mail from postfix" | mail -s "Test Postfix" 73884@qq.com

此时你可以收到一封
主题为 Test Postifx;内容为 Test mail from postfix 的邮件
admin
版权声明:本站原创文章,由 admin2023-02-07发表,共计789字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)