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

Brothers, I have read from the Cookbook Ex. 20.2 in my quest for Perl based website trickery and I am still con-fuse-ed.

Basically I am too cheap to pony up 25USD a year to get POP3 access to Mail.com. So my idea is to have a Perl script (I'm on OSX and they have no tool for OS X to do this like they do for Windows) log onto the website and read the page looking for "You Have New Mail" and if these words appear have the Perl Script send me an email telling me so. I would probably cron job it to do so three or four times a day.

Now Ex 20.2 talks about CGI form filling and I am under the impression that Mail.com is done with Javascript.

Does this change anything? And if so is there a module for this?
There's more than one way to do it, but only some of them actually work.
  • Comment on Entering Username Password on a website

Replies are listed 'Best First'.
Re: Entering Username Password on a website
by BigLug (Chaplain) on Sep 18, 2002 at 04:50 UTC
    Taking a look at the html of their front page, the login procedure is quite simple. Ignore the JavaScript .. thats just so they can do cool things if the login fails.

    The following code is an adaptation of the example in Cookbook 20.2 but is untested as I have no mail.com account :)

    use HTTP::Request::Common qw(POST); use LWP::UserAgent; $ua = LWP::UserAgent->new(); my $req = POST 'http://www.mail.com/scripts/common/proxy.main', [ action => 'login', show_frame => 'Enter', mail_language => 'us', login => 'full@email.address', password => 'yourpassword', ]; $content = $ua->request($req)->as_string; if ($content =~/You Have New Mail/i) { send_an_email() }
      It doesn't work as is. It needs to be able to get the redirected content. On my account, http://www.mail.com/scripts/common/proxy.main redirects to http://mail02.mail.com/scripts/common/outblaze.main and the redirect breaks this script. I seem to remember someone getting a redirect to work with LWP though.

        To enable redirection of POST requests: push @{$ua->requests_redirectable}, 'POST';

Re: Entering Username Password on a website
by Mr. Muskrat (Canon) on Sep 18, 2002 at 19:20 UTC

    Here is all I have right now...

    #!/usr/bin/perl use strict; use warnings; use HTTP::Request::Common qw(POST); use LWP::UserAgent; use HTTP::Cookies; my $ua = LWP::UserAgent->new; push @{$ua->requests_redirectable}, 'POST'; $ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave +=> 1)); my $req = POST 'http://www.mail.com/scripts/common/proxy.main', [ action => 'login', show_frame => 'Enter', mail_language => 'us', login => 'your@mail.com', password => 'password', ]; my $res = $ua->request($req)->as_string; print $res;

    It prints this:

    HTTP/1.0 200 OK Connection: close Date: Wed, 18 Sep 2002 19:12:46 GMT Pragma: no-cache Server: Apache Content-Type: text/html; charset=iso-8859-15 Client-Date: Wed, 18 Sep 2002 19:10:31 GMT Client-Response-Num: 1 Set-Cookie: ob_cookies=; domain=mail02.mail.com; path=/ Title: iname.com X-Cache: MISS from webserver <!-- ws1-11.us4.outblaze.com, 0, Bad authenticator cookie!, , , --><h +tml> <head> <title>iname.com</title> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> </head> <script language="Javascript"> function popUp(url){ window.open(url,'','width=550,height=400,resizable=yes,scrollbars= +yes,menubar=no'); } </script> <link rel="stylesheet" href="http://mail02.mail.com/templates/common/u +s/css.htm"> <body bgcolor="#FFFFFF" topmargin="0" marginheight="2"> <p><center> </center></p> <p><center> <SCRIPT LANGUAGE="JavaScript1.1" SRC="http://oas-central.realmedia.com +/RealMedia/ads/adstream_jx.ads/mail.com/bannertop/1279673@x01?"> </script> <script LANGUAGE="JavaScript"> <!-- _version=10; //--> </script> <script LANGUAGE="JavaScript1.1"> <!-- _version=11; // --> </script> <script LANGUAGE="JavaScript"> <!-- if (navigator.appVersion.indexOf('MSIE 3') != -1){ document.write('<IFRAME WIDTH=468 HEIGHT=60 MARGINWIDTH=0 MARGINHEIGHT +=0 HSPACE=0 VSPACE=0 FRAMEBORDER=0 SCROLLING=no BORDERCOLOR="#000000" + SRC="http://oas-central.realmedia.com/RealMedia/ads/adstream_sx.cgi/ +mail.com/bannertop/1279673@x01?"></iframe>'); } else if (_version < 11) { document.write ('<A HREF="http://oas-central.realmedia.com/RealMedia/a +ds/click_nx.ads/mail.com/bannertop/1279673@x01?" target="_new"><IMG S +RC="http://oas-central.realmedia.com/RealMedia/ads/adstream_nx.ads/ma +il.com/bannertop/1279673@x01?"></a>'); } // --> </SCRIPT> </center><script language="Javascript"> top.document.location.href="http://mail02.mail.com/templates/common/us +/expire.htm"; </script><p><center> <!-- ----------Advertising.com Banner Code---------- --> <SCRIPT LANGUAGE="JavaScript" SRC="http://servedby.advertising.com/sit +e=42011/size=468060/bnum=96107808/optn=1"> </SCRIPT> <NOSCRIPT> <A HREF="http://servedby.advertising.com/click/site=42011/bnum=9610780 +8" TARGET="_blank"><IMG SRC="http://servedby.advertising.com/site=420 +11/size=468060/bnum=96107808/bins=1/rich=0" WIDTH="468" HEIGHT="60" B +ORDER="0" ALT="Click to learn more..."></A> </NOSCRIPT> <!-- ----------Copyright 2000, Advertising.com---------- --> </center> <p><center> </center></p> <p><center><font size="-1" color="#000000">&copy; 2002 Mail.com. All r +ights reserved.</FONT></center> </body> </html>

    What else should we be doing?

Re: Entering Username Password on a website
by Mr. Muskrat (Canon) on Sep 18, 2002 at 17:33 UTC

    Well, now we are getting somewhere but alas! we have forgotten to use HTTP::Cookies. I'll try and work on it after lunch.

Forward your mail.com email to another account
by Mr. Muskrat (Canon) on Feb 20, 2003 at 22:34 UTC

    I found Get mail.com today. Be sure you get the latest version from the CVS.

    Update: You will want to make a few changes to this script as follows:
    Put in your smtp host at line 29 and the email address to send the messages to on line 30. Comment out lines 301 - 305.