-
Notifications
You must be signed in to change notification settings - Fork 72
/
cmdlinetest.php
70 lines (63 loc) · 1.92 KB
/
cmdlinetest.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
<?php
require_once('bounce_driver.class.php');
$total = array();
function checkmail($email) {
global $total;
$bh = new Bouncehandler();
$bounceinfo = $bh->get_the_facts($email);
# var_dump($bounceinfo);
# var_dump($bh);
print "TYPE ". @$bh->type. "\n";
if ($bh->type == 'bounce') {
print "ACTION ". $bounceinfo[0]['action']. "\n";
print "STATUS ". $bounceinfo[0]['status']. "\n";
print "RECIPIENT ". $bounceinfo[0]['recipient']. "\n";
}
if ($bh->type == 'fbl') {
print "ENV FROM ". @$bh->fbl_hash['Original-mail-from']. "\n";
print "AGENT ". @$bh->fbl_hash['User-agent']. "\n";
print "IP ". @$bh->fbl_hash['Source-ip']. "\n";
}
if ($bh->type == 'autoresponse') {
print "AUTO ". $bounceinfo[0]['autoresponse']. "\n";
}
if ($bh->type)
@$total[$bh->type]++;
else
@$total['unknown']++;
print "\n";
}
if (defined('STDIN')) {
if (count($argv) > 1) {
for ($i = 1; $i < count($argv); $i++) {
if (is_dir($argv[$i])) {
$dh = opendir($argv[$i]);
while ($fn = readdir($dh)) {
if (substr($fn,0,1) !== '.') {
$email = file_get_contents($argv[$i].'/'.$fn);
print $argv[1]."/$fn\n";
checkmail($email);
}
}
}
else {
$email = file_get_contents($argv[$i]);
print $argv[1]."\n";
checkmail($email);
}
}
foreach ($total as $k => $v) {
print "$k = $v\n";
}
}
else {
$handle = fopen("php://stdin","r");
$email = stream_get_contents($handle);
fclose($handle);
checkmail($email);
}
foreach ($total as $t => $v) {
printf("%-15s %6d\n", $t, $v);
}
}
?>