-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomputeMySMTP.php
executable file
·29 lines (26 loc) · 1.02 KB
/
computeMySMTP.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
#!/usr/bin/php
<?php
openlog('rblcheck',LOG_PID,LOG_MAIL);
require_once('function.php');
$pslist=parse_ini_file('dnsbl.conf', TRUE);
$items=readList($pslist['lists']['list']);
$ips = parse_ini_file('mySMTP.conf');
$send = FALSE;
foreach ( $ips['ip'] as $ip ) {
$result["$ip"] = checkList($ip, $items, $alert);
if ( $alert ) $send = TRUE;
}
file_put_contents(__DIR__.'/result.json',json_encode($result));
syslog (LOG_INFO, "The check for your SMTP servers has been written.");
if ( $send ) {
/* At least one IP is listed. I send a notification mail */
$opt = parse_ini_file('email.conf', TRUE);
syslog (LOG_EMERG, "At least one of your IP is blocklisted. See urgently at last report {$opt['others']['link']}");
require_once('emailfunction.php');
$message = sprintf("Hello, some of your IPs are blocklisted. I'm sorry, now you must work hard to get IP delisted.\r\n\r\n See at %s", $opt['others']['link']);
if ( emailSent ($opt['mail'], $message, $error) )
syslog (LOG_INFO, $error);
else syslog (LOG_ALERT, $error);
}
exit(0);
?>