File: gen_fetchmail.php

package info (click to toggle)
dtc 0.35.5-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 18,824 kB
  • sloc: php: 50,739; sh: 8,596; makefile: 572; perl: 148; xml: 25
file content (37 lines) | stat: -rw-r--r-- 1,197 bytes parent folder | download
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
<?php

function fetchmail_generate() {
	global $conf_generated_file_path;
	global $console;

	$filename=$conf_generated_file_path.'/fetchmailrc';
	$console.="Generating $filename : ";
	if (touch($filename)) {
		$console.="Done!\n";
	}else{
		$console.="Failed!";
		return false;
	}

	$result=mysql_query("SELECT * FROM fetchmail");
	$num=0;    
	$fetchline="";
	while ($row=mysql_fetch_assoc($result)) {
		if ($row['checkit'] != "yes") continue;
		/* Yes, only pop3 yet. Must specify it, auto is *sloooow* */
		$fetchline.="poll ${row['pop3_server']} proto POP3\n";
		$fetchline.="qvirtual \"MFY\"\n";
		$fetchline.="envelope \"Delivered-To\"\n";
		/* Unfortunately there is no such option in fetchmail to keep mails for X days, or something, so it must be done with
		other tools. I think its safer to keep messages on remote server by default */
		$fetchline.="user ${row['pop3_login']} with password ${row['pop3_pass']} to ${row['domain_user']}@${row['domain_name']}\n";
		$fetchline.="keep\n";

		$num++;
	}
	file_put_contents($filename,$fetchline,LOCK_EX);
	chmod($filename,0600);
	$console.="Number of fetchmailrc entries generated: ".$num."\n";
	updateUsingCron("gen_fetchmail='no'");
}
?>