Ubuntu服务器配置qq邮箱发送信息

效果:
在这里插入图片描述
此处设置的是自己给自己发送,配合linux的cron实现定时触发发送事件的效果

实现过程:

  1. 安装邮箱客户端Postfix
sudo apt-get install postfix
  1. 配置Postfix:编辑Postfix的主要配置文件 /etc/postfix/main.cf,并在最后添加以下参数:
relayhost = [smtp.qq.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
maillog_file = /var/log/mail.log
debug_peer_level = 2
  1. 创建和配置 /etc/postfix/sasl_passwd 文件
    将您的 QQ 邮箱用户名和授权码替换为实际信息
[smtp.qq.com]:587  your_qq_email@qq.com:your_authorization_code
  1. 确保文件可被读取
sudo chmod 600 /etc/postfix/sasl_passwd
  1. 生成 sasl_passwd 文件的哈希映射:
sudo postmap /etc/postfix/sasl_passwd
  1. 重新加载 Postfix 配置:
sudo systemctl reload postfix
  1. 测试结果
    echo “This is a test email” | mail -s “Test Email” -r custom_email@example.com example@qq.com

我这里讲以上两个邮箱地址都设置成了自己的

如遇到问题可执行

sudo cat /var/log/mail.log

查看日志获取进一步信息

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值