Page 1 of 1

Free Perl Pop3 Collector

Posted: 2006-12-18 15:41
by mthosting

Code: Select all

#MT Hosting
#stephen@mthosting.net
#Usage: Run this as a scheduled task to collect external pop3 email and move them into exchange.
use Net::POP3;
use Net::SMTP;

#1 = turn debug on || 0 = turn debug off
#to check for errors run the this from the command line. Example:
# perl exchangepop.pl 1>>expop.log 2>>expop.log
$debug=0;

$inserver="mail.gmail.com"; #email server to get email from

$outserver="localhost"; #Exchange Server, this is usually localhost.

#Accounts to Collect e-mail from, Example:
# 'Pop3 user name' => {'password' =>  'Pop3 Password','sendto' =>  'Exchange E-mail Address',},
%accounts = (
            'demo@demo.na' => {'password' =>  'pop3_pass','sendto' =>  'demo@demo_exchange.local',},
            );

foreach $accnt (keys %accounts)
{
#print "User: $accnt password:", $accounts{$accnt} -> {"password"}, " sendto: ",$accounts{$accnt} -> {"sendto"}," \n";

   $pop = Net::POP3->new($inserver,Timeout => 60, Debug => $debug);
    if ($pop->login($accnt, $accounts{$accnt} -> {"password"}) > 0)
    {
        my $msgnums = $pop->list;
        foreach my $msgnum (keys %$msgnums)
        {
            my $msg = $pop->get($msgnum);
            $smtp = Net::SMTP->new($outserver, Timeout => 60, Debug =>$debug);
            $smtp->mail($accnt);
            $smtp->to($accounts{$accnt} -> {"sendto"});
            $smtp->data();
            $smtp->datasend(@$msg);
            $smtp->dataend();
            $smtp->quit;
            $pop->delete($msgnum);
        }
    }
    $pop->quit;
}
print "done!";

http://www.prolifix.net/exchangepop.pl.txt


Setup:
1. Set $inserver to your incoming mail server to collect the pop3 email from. If you need to collect from multiple pop3 servers just copy the script and run them separately.
2. Set $outserver to the server that you would like to move the email to. It does not have to be a local server.
3. Set the %accounts array with the pop3 account you would like to collect.
If you are collect multiple pop3 accounts %accounts might look like this.

Code: Select all

%accounts = (
            'demo@demo.na' => {'password' =>  'pop3_pass','sendto' =>  'demo@demo_exchange.local',},
             'demo2@demo.na' => {'password' =>  'demo2_pass','sendto' =>  'demo2@demo_exchange.local',},
            ); 

Posted: 2007-06-25 01:31
by TheSeparator
Using this great script, all my incoming message are classified by ASSP as originating from a local domain..... and thus not verified/marked.

How can I avoid this ?

Regards,
TheSeparator

Posted: 2007-07-05 21:42
by mthosting
You can't, as far as the receiver is concerned the mail comes from the local host.


sc

Re: Free Perl Pop3 Collector

Posted: 2008-06-26 20:32
by c0d3r
check out this nice, rich-featured free pop3 collector :
http://users.telenet.be/internet.activi ... 3collector

Re: Free Perl Pop3 Collector

Posted: 2008-07-05 11:38
by ewieldra
@c0d3r

really nice connector