java:如何在不发送确认电子邮件的情况下验证电子邮件地址是否有效?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2356298/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 20:45:43  来源:igfitidea点击:

java: how can i verify an email address to be valid without sending a confirmation e-mail?

javaemail-verification

提问by ufk

when people register to my website i don't want to send them a verification e-mail, i just want to check if that e-mail exists. is there a way to do such a thing ?

当人们注册到我的网站时,我不想向他们发送验证电子邮件,我只想检查该电子邮件是否存在。有没有办法做这样的事情?

using apache-tomcat and java as my main programming language.

使用 apache-tomcat 和 java 作为我的主要编程语言。

thanks a lot!

多谢!

回答by bmargulies

No. There is no way to tell if an email address points to a valid destination. You can check basic syntax, and that the domain has a record in DNS, but that's all.

不可以。无法判断电子邮件地址是否指向有效目的地。您可以检查基本语法,域在 DNS 中有记录,仅此而已。

回答by BalusC

You can at highest use regexto check if the address is syntactically valid and/or looking up the MX recordsif the domain is valid, but this still does not guarantee that the email address is legitimate and belongs to the registrant in question. There is really no more reliable way than sending a verification email and waiting for confirmation in a short time-span.

您最多可以使用正则表达式来检查地址在语法上是否有效和/或在域有效时查找MX 记录,但这仍然不能保证电子邮件地址是合法的并且属于相关注册人。没有比发送验证电子邮件并在短时间内等待确认更可靠的方法了。

回答by delfuego

I just wanted to weigh in and say that despite your reluctance to do so, PLEASE send an email and force the user to confirm that they have control of it before allowing that email address to be used in association with an account on your site. Why? Because not doing that, for any reason, means that users can sign up for accounts using email addresses that aren't theirs. They might do so accidentally, or they might do so very much on purpose (e.g., signing others up for accounts for any number of reasons); that's just not kosher, and websites that allow it are open to being reported to their ISPs.

我只是想权衡一下,尽管您不愿意这样做,但请发送电子邮件并强制用户确认他们可以控制它,然后再允许将该电子邮件地址与您网站上的帐户关联使用。为什么?因为不这样做,无论出于何种原因,都意味着用户可以使用不属于他们的电子邮件地址注册帐户。他们这样做可能是偶然的,也可能是故意这样做的(例如,出于各种原因为他人注册帐户);这只是不符合犹太教规,允许它被报告给他们的 ISP 的网站是开放的。

(I say this as the owner of a Gmail account which, at least two to three times a month, is signed up for an account at some website that doesn't force users to confirm their email addresses in this manner. It's irritating, and it puts the onus on meto get the account removed from the offending website. I've now taken to recovering any passwords I can, logging into the account, and then changing the email address to "[email protected]" or something like that... it's sorta fun, but I doubt you want this to happen on your website.)

(我作为 Gmail 帐户的所有者说这是一个 Gmail 帐户,每个月至少有两到三次,在某个网站上注册一个帐户,该帐户不会强制用户以这种方式确认他们的电子邮件地址。这很烦人,而且它让有责任从违规网站中删除该帐户。我现在已经开始恢复我可以恢复的任何密码,登录该帐户,然后将电子邮件地址更改为“[email protected]”或类似的那...有点有趣,但我怀疑您是否希望这发生在您的网站上。)

回答by delfuego

contrary to some of the uneducated answers you can TRY and connect to an MX server and use the VRFY command to see if the sever supports it. Here is a websitethat will do this for you as an example. If you look at its exchange with the MX server it actually does try and send an email but does a RESET before actually sending it. Testing it with my email address works but I don't get an email. So yes you CAN do what everyone else is saying you can't do. Use an address you know works for your domain, then use one that you don't isn't supported. You will get a 550 on the last RCTP TO command. That is how you know it doesn't exist.

与一些未受过教育的答案相反,您可以尝试连接到 MX 服务器并使用 VRFY 命令查看服务器是否支持它。这是一个网站,可以为您做这件事作为示例。如果您查看它与 MX 服务器的交换,它实际上确实尝试发送电子邮件,但在实际发送之前会进行重置。用我的电子邮件地址测试它有效,但我没有收到电子邮件。所以是的,你可以做其他人说你不能做的事情。使用您知道适用于您的域的地址,然后使用您不支持的地址。您将在最后一个 RCTP TO 命令上得到 550。这就是你知道它不存在的方式。

回答by Mike

This has been answered already in previous questions here. Without a verification email, the best you can do is look at the email address and look if it seems valid. You can also check things such as the domain, to see if it exists and has MX records. Anyway, see https://stackoverflow.com/questions/3232/how-far-should-one-take-e-mail-address-validationand Using a regular expression to validate an email address

这已经在以前的问题中得到了回答。如果没有验证电子邮件,您能做的最好的事情就是查看电子邮件地址,看看它是否有效。您还可以检查域等内容,以查看它是否存在并具有 MX 记录。无论如何,请参阅https://stackoverflow.com/questions/3232/how-far-should-one-take-e-mail-address-validation使用正则表达式验证电子邮件地址

回答by No Refunds No Returns

If you just want to verify that it LOOKs like a valid email address, there are many sample Regex's that will verify that. If you want to verify the user has control of the email address, you'll need to send something to it and craft a unique response to verify it.

如果你只是想验证它看起来像一个有效的电子邮件地址,有许多示例 Regex 可以验证它。如果您想验证用户对电子邮件地址的控制权,您需要向它发送一些内容并制作一个独特的响应来验证它。

回答by z-index

You can use the openid service to check for valids email addresses as stackoverflow does.

您可以像 stackoverflow 一样使用 openid 服务来检查有效的电子邮件地址。

http://openid.net/

http://openid.net/

回答by AccuWebHosting.Com

Email Verification servicesare very helpful in validating email address. Most of them performs 6 levels of verification like syntax validation, Domain MX record Check, Role based Account detection, Disposable email address (DEA) detection, HoneyPot/Spam track detection and deep level SMTP verification.

电子邮件验证服务对验证电子邮件地址非常有帮助。它们中的大多数执行 6 个级别的验证,如语法验证、域 MX 记录检查、基于角色的帐户检测、一次性电子邮件地址 (DEA) 检测、蜜罐/垃圾邮件跟踪检测和深层 SMTP 验证。

Most of them offers API integration, so, you can directly validate email addresses from your application.

它们中的大多数都提供 API 集成,因此,您可以直接从应用程序验证电子邮件地址。