当需要对任何域的SPF记录进行重新处理和进一步处理时,我需要使用PHP + Ext JS创建简单的代码。
我找到了类似的网站 http://www.kitterman.com/spf/validate.html 我可以在网站上获得SPF记录。
但我需要在PHP + JS代码中使用此信息,我需要处理它,以显示并保存新更新的。
PHP JS中是否有任何命令可以获取SPF记录并保存?
Urmas。
答案 0 :(得分:5)
SPF是一个txt DNS记录,因此只需使用dns_get_record ($hostname , DNS_TXT)
获取所有txt记录(它返回一个数组)并检查每个记录是否包含v=spf1
答案 1 :(得分:1)
你应该考虑到SPF标准非常复杂,并且有许多人做错了。我建议你仔细阅读,以确保你的实施涵盖了你需要的所有检查。
这是了解有关SPF的更多资源: http://www.openspf.org/SPF_Record_Syntax
以下是技术文档: http://tools.ietf.org/html/rfc4408
除了获取域的TXT记录之外,还有更多内容。对于早于5的PHP版本,您可以在基于unix的系统上使用shell_exec("dig example.com TXT @nameserver");
。
答案 2 :(得分:0)
检查此代码。对某人可能会有帮助
<?php
include("util.php");
$exists = false;
$array = dns_get_record("amazon.com", DNS_ALL);
for ($i = 0; $i <= count($array) - 1; $i++) {
$nestedarray = $array[$i];
for ($j = 0; $j <= count($nestedarray) - 1; $j++) {
if (array_key_exists("txt", $nestedarray)) {
$str = $nestedarray['txt'];
$search = "v=spf1";
if (preg_match("/{$search}/i", $str)) {
echo (prepareAPIResponse("success", $str, "found"));
$exists = true;
break;
}
}
}
}
if (!$exists) {
echo (prepareAPIResponse("error", null, "not found"));
}
function prepareAPIResponse($status='success', $data=null, $msg=null)
{
header('content-type: application/json');
return json_encode([
'status'=>$status,
'data'=>$data,
'message'=>$msg
]);
}