-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfetchmail.php
53 lines (45 loc) · 1.15 KB
/
fetchmail.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
<?php
require_once 'config.inc.php';
if(isset($conf['query'][$conf['querytype']])) {
try {
$stmt = $db->query($conf['query'][$conf['querytype']]);
$rows = $stmt->fetchAll(PDO::FETCH_CLASS, 'ArrayObject');
} catch(PDOException $e) {
echo $e->getMessage() . "\n";
exit (1);
}
} else {
echo 'Query type ' . $conf['querytype'] . ' is not defined.' . "\n";
exit(1);
}
if(count($rows) > 0)
{
$fetchmailrc = $conf['default_options'];
foreach($rows as $row)
{
if( !empty($row->remoteserver)
&& !empty($row->remoteuser)
&& !empty($row->remotepass)
&& !empty($row->destination))
{
if(!empty($row->options))
$row->options = 'options ' . $row->options;
$fetchmailrc .= <<<EOF
# -------------------------
poll $row->remoteserver
proto pop3
user "$row->remoteuser"
pass "$row->remotepass"
is $row->destination
$row->options
EOF;
}
}
}
if(!isset($fetchmailrc)) {
$fetchmailrc = '';
}
$fp = fopen($conf['fetchmailrc'], 'w');
fwrite($fp, $fetchmailrc);
fclose($fp);
chmod($conf['fetchmailrc'], 0600);