SF.net SVN: postfixadmin: [147] trunk/ADDITIONS/fetchmail.pl
Brought to you by:
christian_boltz,
gingerdog
|
From: <chr...@us...> - 2007-10-09 23:48:45
|
Revision: 147
http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=147&view=rev
Author: christian_boltz
Date: 2007-10-09 16:48:48 -0700 (Tue, 09 Oct 2007)
Log Message:
-----------
- initial version of fetchmail support (by Viktor Gotwig,info AT symateam.de)
(see postfixadmin-devel mailinglist for detailed description and known
problems, subject "fetchmail support").
This commit adds fetchmail.pl which was missing in r140
Added Paths:
-----------
trunk/ADDITIONS/fetchmail.pl
Added: trunk/ADDITIONS/fetchmail.pl
===================================================================
--- trunk/ADDITIONS/fetchmail.pl (rev 0)
+++ trunk/ADDITIONS/fetchmail.pl 2007-10-09 23:48:48 UTC (rev 147)
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+use DBI;
+use MIME::Base64;
+use Data::Dumper;
+
+# the home dir of vmail user:
+$vmail_dir="/home/maildirs";
+
+# mysql settings
+$database="mailadmin";
+$hostname="127.0.0.1";
+$user="mail";
+$password="*****";
+$dsn = "DBI:mysql:database=$database;host=$hostname";
+
+#mysql connect
+$dbh = DBI->connect($dsn, $user, $password) || die "cannot connect the database";
+
+$sql=<<SQL;
+SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options
+FROM fetchmail
+WHERE unix_timestamp(now())-unix_timestamp(date) > pool_time*60
+SQL
+
+my (%config);
+map{
+ my ($id,$mailbox,$src_server,$src_auth,$src_user,$src_password,$src_folder,$fetchall,$keep,$protocol,$mda,$extra_options)=@$_;
+
+ $cmd="user '${src_user}' there with password '".decode_base64($src_password)."'";
+ $cmd.=" folder '${src_folder}'" if ($src_folder);
+ $cmd.=" mda ".$mda if ($mda);
+
+# $cmd.=" mda \"/usr/local/libexec/dovecot/deliver -m ${mailbox}\"";
+ $cmd.=" is '${mailbox}' here";
+
+ $cmd.=" keep" if ($keep);
+ $cmd.=" fetchall" if ($fetchall);
+ $cmd.=" ".$extra_options if ($extra_options);
+
+ $text=<<TXT;
+set postmaster "postmaster"
+set nobouncemail
+set no spambounce
+set properties ""
+
+poll ${src_server} with proto ${protocol}
+ $cmd
+
+TXT
+
+ open X,"> ${vmail_dir}/.fetchmailrc" || die "cannot open/create ${vmail_dir}/.fetchmailrc";
+ print X $text;
+ close X;
+ chmod 0600,"${vmail_dir}/.fetchmailrc";
+ $ret=`/usr/bin/fetchmail`;
+ $sql="UPDATE fetchmail SET returned_text=".$dbh->quote($ret).", date=now() WHERE id=".$id;
+ $dbh->do($sql);
+
+}@{$dbh->selectall_arrayref($sql)};
+
+unlink "${vmail_dir}/.fetchmailrc";
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|