惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

程序猿DD

2.1K Star,一个帮你自动完成JavaDoc注释的IDEA插件 Java 21 新特性:String Templates(字符串模版) 14.4K Star,一款漂亮、快速、现代化的开源UI组件库 推荐一款免费好用的远程桌面:Getscreen 34.9K Star!超受欢迎的开源免费后台模版:tabler 10.4K Star!程序员为程序员针对性优化的开源免费笔记 开源免费、开箱即用的中后台管理模版:vue-pure-admin Java自带的4种字符串组织和格式化方法 开源免费的文件投喂与问答工具,构建你的第二大脑:Quivr 内网穿透最好用的还得是ngrok,一行命令就搞定! 一款开源免费、更符合现代用户需求的论坛系统:vanilla 一款极具潜力的开源免费数据库管理工具:slashbase 69.9K Star,最强开源内网穿透工具:frp 效率神器!浏览器自动化操作插件:Automa Notion的开源替代方案:AFFiNE 你的Spring Boot应用启动很慢?不妨试试这个工具! 一款滴滴开源的流程图编辑框架:LogicFlow 基于Spring Boot 3的开源培训系统,学习和自用都不错 Spring 6.1新特性:RestClient
Spring Boot通过企业邮箱发邮件被Gmail退回的问题解决方法
2023-08-17 · via 程序猿DD

这两天给我们开发的Chrome插件:Youtube中文配音增加了账户注册和登录功能,其中有一步是邮箱验证,所以这边会在Spring Boot后台给用户的邮箱发个验证信息。如果发邮件,之前的文章教程里就有,这里就不说了,着重说说这两天发现所有用Gmail注册的用户都被退件的问题。

报错现象

先来看看具体报错(如果您也碰到这种情况,那么可以看看后面的内容):

退信原因:发件人(youtubedubbing@mail.spring4all.com)域名的DNS记录未设置或设置错误导致对方拒收此邮件。
host gmail-smtp-in.l.google.com[142.251.10.26] said: 550-5.7.26 This mail is unauthenticated, which poses a security risk to the sender and Gmail users, and has been blocked. The sender must authenticate with at least one of SPF or DKIM. For this message, DKIM checks did not pass and SPF check for [mail.spring4all.com] did not pass with ip: [54.204.34.130]. The sender should visit https://support.google.com/mail/answer/81126#authentication for instructions on setting up authentication. k191-20020a636fc8000000b00565bcd33890si6279798pgc.848 - gsmtp (in reply to end of DATA command)
解决方案:请通知你的邮箱管理员为邮箱域名设置正确的DNS(SPF、DKIM、DMARC)记录。详细请见 http://service.exmail.qq.com/cgi-bin/help?subtype=1&&no=1000580&&id=20012

问题分析

从退信原因中Google给的链接内容非常多,大致内容就是Google针对垃圾邮件滥用邮箱等行为做的防护机制。所以,如果您要支持Gmail的话,就必须符合它所制定的身份配置要求,里面包含了:SPF配置、DKIM配置、ARC配置以及DMARC配置。

Google官方提供了一个工具:https://toolbox.googleapps.com/apps/checkmx/,可以用来检测你的一些列配置是否符合要求。您只需要输入你的邮箱域名,就可以看到如下的诊断结果:

那么多警告,显然是要慢慢解决才能不被拒收吧。。。不过那么多配置,是不是一下就晕了?

如果你懒得深入看的话,下面DD就讲一下比较快速的解决不被拒收的配置。

解决方案

不要看有那么多警告和配置内容,其实只需要把SPF配置完成,Gmail的发送就不成问题了。配置方法也很简单,就是在域名解析里加一条记录即可。

Gmail官网也给出了介绍:

但第一次也许你会跟我犯一样的错,就是直接用v=spf1 include:_spf.google.com ~all这个value了。。。其实应该要修改成你所用企业邮箱服务商的spf域名。

比如,DD这边用的是腾讯的企业邮箱,所以值要设置成:v=spf1 include:spf.mail.qq.com ~all。直观的讲,你的域名解析里需要有这样一条TXT记录:

SPF汇总

这边汇总一下,国内比较常用的企业邮箱SPF配置,如果您正好碰到类似问题,可以直接选取使用:

  • 腾讯企业邮箱:v=spf1 include:spf.mail.qq.com ~all
  • 阿里企业邮箱:v=spf1 include:spf.mxhichina.com -all
  • 网易企业邮箱:v=spf1 include:spf.163.com -all

今天的分享就到这里,希望对您有所收获!码字不易,欢迎关注、收藏、分享,支持一下。本文可以任意转载,但请注明原文链接 ^_^