Free Perl Pop3 Collector

This section contains scripts that hMailServer has contributed with. hMailServer 4 is needed to use these.
Post Reply
mthosting
Normal user
Normal user
Posts: 38
Joined: 2006-06-21 01:51
Location: NYC
Contact:

Free Perl Pop3 Collector

Post by mthosting » 2006-12-18 15:41

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',},
            ); 

TheSeparator
New user
New user
Posts: 1
Joined: 2007-04-11 02:01

Post by TheSeparator » 2007-06-25 01:31

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

mthosting
Normal user
Normal user
Posts: 38
Joined: 2006-06-21 01:51
Location: NYC
Contact:

Post by mthosting » 2007-07-05 21:42

You can't, as far as the receiver is concerned the mail comes from the local host.


sc

c0d3r
New user
New user
Posts: 1
Joined: 2008-06-26 20:28

Re: Free Perl Pop3 Collector

Post by c0d3r » 2008-06-26 20:32

check out this nice, rich-featured free pop3 collector :
http://users.telenet.be/internet.activi ... 3collector

ewieldra
Normal user
Normal user
Posts: 37
Joined: 2008-04-24 23:23
Location: The Netherlands

Re: Free Perl Pop3 Collector

Post by ewieldra » 2008-07-05 11:38

@c0d3r

really nice connector
Best regards,

Emiel Wieldraaijer
The Netherlands

Post Reply