除了电子邮件验证之外还有其他方法吗?
如果不升级,我就无法访问 SMTP 服务器,现在还不能。
我可以使用任何其他方法来确保用户在我的数据库中输入有效的电子邮件地址。至少在接下来的几周内,我必须使用免费的网络主机(目前是 xtreemhost)。我刚刚完成了该网站,想先测试一下。
我的网站使用 php-mysql。
I don’t have access to a SMTP server without upgrading, which I can’t right now.
Is there any other method that I can use to ensure that users enter valid email addresses in my database. I have to go on a free web host (currently xtreemhost) for at least the next few weeks. I just finished the site and want to test it first.
I use php-mysql for the website.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
简介
您可以验证电子邮件的表单,这意味着您可以判断它是否是有效的电子邮件地址,但您无法检查该电子邮件地址是否确实存在。
回答
至于验证本身,有很多方法可以实现,
其中一种是使用
filter_var()
旁注:不建议使用 REGEX 来验证电子邮件。如果你这样做了,乔恩·斯基特会在晚上来找你。
Introduction
You can validate the email's form, meaning you can tell if it's a valid email address, but you cannot check whether the email address actually exists.
Answer
As for the validation itself, there are many ways of doing it,
One would be to use
filter_var()
Side Note: REGEX is not recommended to verify emails. If you do, Jon Skeet will come to you at night.
您可以做的事情之一是通过 WHOIS 查找或 ping 检查域名是否有效。如果有人输入 [email protected],您会尝试 whois 查找 doe.com 并也可以 ping 该域。如果域不存在,则电子邮件无效。
另外,要求输入电子邮件两次对我来说也有好处——人们不再在电子邮件中犯拼写错误。
此外,通过正则表达式对电子邮件进行良好的验证也是必须的。
One of the things you can do is check if domain is valid via WHOIS lookup or ping. If somebody enters [email protected] you try to whois lookup doe.com and ping that domain as well. If domain does not exists, email is not valid.
Also asking to type email twice does a good job for me - people stop making spelling mistakes in their emails.
Also good validation via regexp for an email is must-have.
这是我最常看到的从最简单到最准确的列表。
正则表达式 - 检查并确保它是有效的电子邮件格式。我在 Stack Overflow 上看到了一些很好的代码片段——免费且简单,但无法确定电子邮件甚至域名是否确实存在。
使用商业解决方案 - 最准确(验证实际电子邮件地址是否有效并可以接受消息),易于实施 (REST/SOAP),但不是免费的
希望这会有所帮助。
Here is the list going from simplest to most accurate that I have seen most often.
Regex - check and make sure it is a valid email format. I have seen some good code snippets on Stack Overflow for this - free and simple but doesn't determine if the email, or even the domain, actually exists.
Check if the domain has an MX-Server - More accurate then regex since at least the domain is checked in realtime - free and fairly simple to implement but doesn't determine if the user exists.
Use a commercial solution - most accurate (verifies the actual email address is valid and can accept messages), simple to implement (REST/SOAP), but not free
Hope this helps.