[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-WebCGI] retrieving email with Perl



David Seay <g-s@navix.net>  originally asked...
>>Is there a way to have Perl retrieve or even receive email?
>>
>>In this project Perl will generate and send email to a list of
>>addresses of folks who have requested specific information.
>>That part I can already do.
>>
>>I would like to have an address in the email's 'From:' field
>>so that when an individual replies to the message the reply will
>>be sent somewhere where Perl can access it and 'automatically'
>>remove that individual's email address from the list of addresses.


Bill Stephenson <bill@secureshopper.com> replied...
>This might be done with a "Cron" type utility

Thanks for the suggestion but the ISP will not allow cron jobs on its
server. The project is for a client who wants all processing to be done
online.


"Tom Salmon" <salmo004@tc.umn.edu> replied...
>This message was posted recently and I didn't see a reply to the entire
>list but am curious as to a solution. Please send me some information on
>this as I am looking to do the same thing.


The following are replies I got from a local Perl Mongers list. I have not
yet tested any of the code or other suggestions. I would appreciate hearing
from anyone who has success with any of these or other methods.

My temporary workaround for this project is to retrieve the email with
Eudora Light (on my mac) which is set to filter these emails into a
particular mailbox. Then I use a MacPerl script to parse the mailbox file
and then process the info. This works but requires human intervention, or
at least that my Mac be turned on.


David Seay


--------------------------------------
REPLY 1
--------------------------------------

    You can use the Mail::POP3Client module to access POP3  mailboxes. 
There's also a Mail::IMAPClient module as well.  I'll  include a quick
script from the code that prints out the subject and >from  lines.  You
could easily modify it to only print out the FROM: lines, and  remove those
from your list.   As for the mailer, I would reccommend using the
Mail::Bulkmail  module, which allows you to send mail to a list of
addresses contained in a  file.   Take a look at all the Mail modules
available at :
http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?join=and;arrange=file;download
=auto;stem=no;case=clike;site=ftp.funet.fi;age=&request=mod&letter=Mail


   From the Mail::POP3Client Docs:

#!/usr/local/bin/perl

   use Mail::POP3Client;

   $pop = new Mail::POP3Client( USER      => "me",
       PASSWORD =>  "mypassword",
       HOST      => "pop3.do.main" );

  for ($i = 1; $i <= $pop->Count(); $i++)  {
      foreach ( $pop->Head( $i ) )  {
          /^(From|Subject):\s+/i and print  $_, "\n";
      }
      print "\n";
  }



--------------------------------------
REPLY 2
--------------------------------------

I didn't have time to read it all, but this package looks like it may be what
you want.  It comes with the perl code and HTML templates to use if you wish to
display the email on a web page.

Product Information Page:
http://www.endymion.com/products/mailman/standard.htm

Download Page:
http://www.endymion.com/products/mailman/download.htm



--------------------------------------
REPLY 3
--------------------------------------

Try using one of these:

Net::POP3  - Post Office Protocol 3 Client class (RFC1081) or
Mail::POP3Client  - Perl 5 module to talk to a POP3 (RFC1939) or, if you're
stuck on NT, try ASPPOP3 from www.serverobjects.com.

I'd bet the Net:: mod will be available.



--------------------------------------
REPLY 4
--------------------------------------

I saw something in the book entitled, Mastering Regular Expressions, by
Jeffrey e.f. Friedl on page p316 that will help you decode mail headers.




==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org