博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
dns的a记录和mx记录_PHP电子邮件验证程序–电子邮件MX DNS记录检查
阅读量:2514 次
发布时间:2019-05-11

本文共 1718 字,大约阅读时间需要 5 分钟。

dns的a记录和mx记录

Validating an email address is one of the hardest feats on the web. A valid email can be marketing gold, but an invalid email address is dead weight. Not only does it require a CPU-taxing PHP regular expression ("/^[A-z0-9\._-]+"."@" . "[A-z0-9][A-z0-9-]*". "(\.[A-z0-9_-]+)*"."\.([A-z]{2,6})$/"), the regular expression can be useless even after it's validated for format if the domain doesn't exist. A regular expression simply wont do -- we need to think more low-level. What does email at any domain require? A DNS MX record. Well, PHP provides a great solution to validate that there's a MX record for the provided email address' domain.

验证电子邮件地址是网络上最艰巨的任务之一。 有效的电子邮件可以是行销黄金,但是无效的电子邮件地址是自重。 它不仅需要占用CPU资源PHP正则表达式( “ /^[A-z0-9\._-]+"."@”。“ [A-z0-9] [A-z0-9-] *“。”(\。[A-z0-9 _-] +)*“。” \。([Az] {2,6})$ /“ ),即使经过格式验证,正则表达式也可能无用如果该域不存在。 正则表达式根本行不通-我们需要考虑更底层的内容。 任何域的电子邮件都需要什么? DNS MX记录。 嗯,PHP提供了一个很好的解决方案,用于验证所提供的电子邮件地址的域是否存在MX记录。

代码 (The Code)

function domain_exists($email, $record = 'MX'){	list($user, $domain) = split('@', $email);	return checkdnsrr($domain, $record);}

用法 (The Usage)

if(domain_exists('user@davidwalsh.name')) {	echo('This MX records exists; I will accept this email as valid.');}else {	echo('No MX record exists;  Invalid email.');}

You'll see that MX is the default record check, though you could change that to A if you want. This method is not bulletproof but the function does provide a compelling enough argument for an email existing or being a fraud. If a valid email address is important for your purposes, use this function. Try it for yourself!

您会看到MX是默认的记录检查,尽管您可以根据需要将其更改为A。 此方法不是防弹的,但是该功能确实为存在的电子邮件或欺诈邮件提供了足够有说服力的论据。 如果有效的电子邮件地址对您的目的很重要,请使用此功能。 自己尝试一下!

翻译自:

dns的a记录和mx记录

转载地址:http://vvpwd.baihongyu.com/

你可能感兴趣的文章
jquery是如何清除ajax缓存的
查看>>
Android核心分析(转载)
查看>>
自学_HTML<一>
查看>>
IOS 发布 升级新版本
查看>>
上传绕过补充
查看>>
sql-leetcode Consecutive Numbers
查看>>
C# winform DataGridView操作 (转)
查看>>
一致性Hash算法及使用场景
查看>>
JS - Lexical Structure
查看>>
【2】oracle创建表空间
查看>>
剑指offer-二叉树中和为某一值的路径
查看>>
Java反射机制
查看>>
Python 正则表达式
查看>>
C++ AppendMenu
查看>>
在所选中的物体中取消选中一些物体.txt
查看>>
grid - 网格项目跨行或跨列
查看>>
Shell 基本运算符
查看>>
2019年2月
查看>>
Google Noto Sans CJK 字体
查看>>
ES集群性能调优链接汇总
查看>>