Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

how can i retrieve pop3 emails for multiple users and then process it?

by hweefarn (Acolyte)
on Dec 29, 2003 at 11:17 UTC ( [id://317407] : perlquestion . print w/replies, xml ) Need Help??

hweefarn has asked for the wisdom of the Perl Monks concerning the following question:

hi :) i am currently in my final year of study and i am in the process of finishing my tesis project. so, i need some suggestion or opinion from u guys to make my project more perfect :)

my project is something like an email utility. when new incoming email arrive at my server, a program will be invoked to process the email. for example, base on the user defined rules, the email will be filtered and then save into certain folder, or automatically forward that email to another email account.

i have finish doing this program using perl. now my problem is at users part. since i dont have a real domain or mail server, i make assumption that all my users has an account at a pop3 server. they must give me their user ID and password so that i can help them to retrieve their email and process it. when i testing my program, i use fetchmail to retrieve the email from the pop3 server. then i use procmail to invoke my program that i just write and also i use procmail to put the email into default mailbox such as /var/spool/mail/a etc.

but now, i am thinking that this solution may not be appropriate, because a user at my server may has username here as A but his pop3 email account may be abraham@tm.net.my. this will bring problem for me when i want to use procmail to filter the receipeint name and put the email into correct mailbox. further more, it seems like unsecure because they need to give me their user id and password.

so, i am seeking for a better solution. anyone can give me any idea? by the way, if i want to write a script to retrieve pop3 emails for multiple users, what modules can i use?

thank you very very much :)

hweefarn
  • Comment on how can i retrieve pop3 emails for multiple users and then process it?

Replies are listed 'Best First'.
Re: how can i retrieve pop3 emails for multiple users and then process it?
by rob_au (Abbot) on Dec 29, 2003 at 12:01 UTC
    but now, i am thinking that this solution may not be appropriate, because a user at my server may has username here as A but his pop3 email account may be abraham@tm.net.my. this will bring problem for me when i want to use procmail to filter the receipeint name and put the email into correct mailbox.

    Fetchmail does already support the specification of different usernames and passwords (from that of the local user account) for remote mail servers. Differing local user accounts can be specified within fetchmailrc files through the here directive - For example:

    poll mail.remotehost.com protocol pop3 port 110 user "user@remotehost.com" with pass "password" is "me@localhost" +here

     

    by the way, if i want to write a script to retrieve pop3 emails for multiple users, what modules can i use?

    There are a multitude of modules available - The following are those which I think merit your attention primarily:

    Of these modules, Mail::Audit will be of the most interest to you from the perspective of the handling, filtering and delivery of mail messages - This module is very well documented and there is also an excellent introductory article for this module in Issue 18 of The Perl Journal here.

    The Mail::POP3Client and Mail::IMAPClient modules will be of use in the retrieval of messages from external mail servers via POP3 and IMAP4 respectively.

     

    perl -le "print+unpack'N',pack'B32','00000000000000000000001010100000'"

Re: how can i retrieve pop3 emails for multiple users and then process it?
by Corion (Patriarch) on Dec 29, 2003 at 12:05 UTC

    I did /msg you this already, but as there now is another reply to this node, I'll also post it here as a reply:

    Please read the documentation on both, fetchmail and procmail. I am fairly confident that they can be configured and work to fetch mail from a list of various hosts under various user names and deliver them locally to various users.

    And please do not post any off-topic questions here. I normally do not object to such, but your postings have nothing to do with Perl and could have been solved by looking at the documentation of the relevant programs.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web