-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Trusted-Sender-DMARC.php
79 lines (73 loc) · 2.43 KB
/
Trusted-Sender-DMARC.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Created by tothebeatceo
* @author Dave Barnes [email protected]
* @version 1.0
* @license MIT License
* @description: The algorithm loops through the input domain
* to ascertain if a DMARC record exists and if it does exist
* then does the record protect the domain with a reject or quarantine
* policy for 100% of all mail, sp policeis must not differ or it will return false
* User: Dave
* Date: 18/05/2018
* Updated: 05/09/2019
* Time: 12:46 AM
*/
function setDMARCpof($vargetURL)
{
$domain = "_dmarc." . $vargetURL;
/**
* @var $showResult array or string get the DNS entry for _dmarc.domain.com
*/
$showResult = dns_get_record($domain, DNS_TXT);
if (!$showResult) {
return false;
} else {
$j = count($showResult);
$i = 0;
if ($j > 1) {
while ($i <= $j) {
If (strpos($showResult[$i]["txt"], "DMARC1") > 0) {
$varDMARC = $showResult[$i]["txt"];
}
$i++;
}
}else {
$varDMARC = $showResult[$i]["txt"];
}
If (strpos($varDMARC, "DMARC1") < 1) {
echo $varDMARC;
return false;
} else {
//////////// this is the code to ascertain safetyfom DMARC
If (strpos($varDMARC, "none") > 1) {
return false;
} elseif (strpos($varDMARC, "reject") > 1) {
if (strpos($varDMARC, "pct=") > 1) {
if (strpos($varDMARC, "pct=100") > 1) {
return true;
}
return false;
// echo "Percentage fail";
} else {
// echo "Good and Percentage Good";
return true;
}
} elseif (strpos($varDMARC, "quarantine") > 1) {
if (strpos($varDMARC, "pct=") > 1) {
if (strpos($varDMARC, "pct=100") > 1) {
return true;
// echo "Quarantine Percentage is good";
}
return false;
// echo " Q Percentage fail";
} else {
return true;
// echo "Q Good and Percentage Good";
}
}
}
}
}
//}
?>