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

We have a number of test email accounts on all the major providers (@aol, @gmail, @hotmail, @yahoo) and I would like to write a script that I can kick off and automatically monitor and extract email from all of them, as I need to check for the existence of specific daily email messages.
In the past I have used Net::POP3 for other type scripts but I do not think I can do that with hotmail. I would like to use PERL for this but don't really know if it's feasible. Can someone point me in the right dir in ref to this?
Thanks in advance.

Replies are listed 'Best First'.
Re: Extracting email with PERL-
by bowei_99 (Friar) on Aug 05, 2009 at 06:47 UTC
    You might try WWW::Hotmail. FYI, for future reference, going to http://search.cpan.org is a good start. From that cpan page:
    use WWW::Hotmail; my $hotmail = WWW::Hotmail->new(); $hotmail->login('foo@hotmail.com', "bar") or die $WWW::Hotmail::errstr; my @msgs = $hotmail->messages(); die $WWW::Hotmail::errstr if ($!); print "You have ".scalar(@msgs)." messages\n"; for (@msgs) { print "messge from ".$_->from."\n"; # retrieve the message from hotmail my $mail = $_->retrieve; # deliver it locally $mail->accept; # forward the message $mail->resend('myother@email.address.com'); # delete it from the inbox $_->delete; } $hotmail->compose( to => ['user@email.com','otheruser@otheremail.com'], subject => 'Hello Person!', body => q[Dear Person, I am writing today to tell you about something important. Thanks for all your support. Sincerely, Other Person ]) or die $WWW::Hotmail::errstr;

    -- Burvil

Re: Extracting email with PERL-
by marto (Cardinal) on Aug 05, 2009 at 08:05 UTC

    'In the past I have used Net::POP3 for other type scripts but I do not think I can do that with hotmail.'

    Yes you can.

    Martin

Re: Extracting email with PERL-
by Marshall (Canon) on Aug 05, 2009 at 03:05 UTC
    I have a project on the back-burner for something like this. POP3 downloads the messages. You probably need POP5 which allows you to inspect and selectively download messages?

    The last time I looked at this, the POP clients that I needed weren't ported to ActiveState Perl yet and were only available on Unix Perl 5.8 and above. There were some other problems in that the more advanced POP clients did a better job of parsing these multi-part fancy e-mail messages. I would be curious if other Monks have gotten fancy e-mail clients to work on ActiveState. It turns out that parsing an e-mail from many clients with potentially many attached files is non-trivial.

Re: Extracting email with PERL-
by Anonymous Monk on Aug 06, 2009 at 01:24 UTC

    In fact, I think you need to go the POP3 (/IMAP) route. From the "Hotmail" (/Windows Live/whatever) Service Agreement:

    you may not: ...
  • use any automated process or service to access and/or use the service (such as a BOT, a spider, periodic caching of information stored by Microsoft, or "meta-searching");
  • (emphasis mine above)

    In other words, no scraping allowed. Use the legitimate interfaces and you'll be fine. And you can indeed do this with a Perl (the language) script... generally you run those with perl (the interpreter). What is PERL? I have not heard of this contraption... ;)