I am reposting this under different header so that people may get a chance to see. Please ignore if you have already read.
It is HERE. Which lets you get your mail to local email service provider or even down to your Linux box which has SMTP/POP3 or IMAP server setup. It needs lots of modules from CPAN, go and get'm from search.cpan.org HTML::Form, LWP, HTTP::Cookies, IO::String, HTML::SimpleParse, Digest::MD5, Net::SMTP http://search.cpan.org/search?dist=libwww-perl http://search.cpan.org/search?dist=IO-String http://search.cpan.org/search?dist=HTML-SimpleParse http://search.cpan.org/search?dist=Digest-MD5 (optional right now no need for installation) http://search.cpan.org/search?dist=libnet For most of these modules Just get them and untar and change to the respective folders Run perl Makefile.PL; make test && make install for each modules from their respective directory. make sure the modules get installed properly. One or two fails during test is fine or Ignore them **Or don't ask me I didnot write those modules**. replace XXXXXX and XXXXXXXXX for $password, $usename and also replace $fromaddr, $toaddr and $fromdomain This actually gets each email from your inbox and send it to your email server or wherever you want it to. Don't get exicted too much. Just run it, fine tune it to match whatever it needs to be. May be there are bugs. It is just the crude implementation so don't write me back asking for features. I am giving for our list just because I think this will be the right time to do so. Anyway I am going to spend little more time on tuning up this script or even putting it as a Perl Module, that too if I get a chance. That is it. ENJOY. Sorry No more Fixes from me after this. #!/usr/bin/perl -w use HTML::Form; use LWP; use HTTP::Cookies; use IO::String; use HTML::SimpleParse; use Digest::MD5 qw( md5_hex ); use Net::SMTP; sub unescape { my ($string) = @_; return undef unless defined($string); my $latin = 1; $string=~ s[&(.*?);]{ local $_ = $1; /^amp$/i ? "&" : /^quot$/i ? '"' : /^gt$/i ? ">" : /^lt$/i ? "<" : /^#(\d+)$/ && $latin ? chr($1) : /^#x([0-9a-f]+)$/i && $latin ? chr(hex($1)) : $_ }gex; return $string; } $| = 1; my $uri = "https://login.yahoo.com/config/login"; my $UA = new LWP::UserAgent; my $HOME = $ENV{'HOME'}; $UA->cookie_jar(HTTP::Cookies->new(file => "$HOME/tmp/yahoo.cookies.txt",autosave => 1)); $UA->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); my $REQ = new HTTP::Request POST => $uri; # # Change this # my ($password, $usename) = ('XXXXXXX', 'XXXXXXXXX'); my ($fromaddr, $toaddr) = ('[EMAIL PROTECTED]', '[EMAIL PROTECTED]',); my $fromdomain = 'zzz.com'; my $res = $UA->request($REQ); if($res->is_success) { my $ct = $res->content_type || ""; my $base = $res->base; my $content = $res->content; my $status = $res->code; if ($ct eq 'text/html') { my @forms = HTML::Form->parse($content, $res->base); my $form = $forms[0] if @forms; # Not yet done. This is for actually sending the password # as MD5 hash to server by which yahoo supports not to # send the password as plain text #my $challenge = $form->value(".challenge"); #my $hash = md5_hex($password.$challenge); $form->value(passwd => $password); $form->value(login => $usename); my $req = $form->click; my $content = $req->content(); my $lreq = new HTTP::Request GET => $req->uri."&".$content; $res = $UA->request($lreq); $REQ->uri('http://us.f134.mail.yahoo.com/ym/ShowFolder?rb=Inbox&YY=7176&YN=1 '); $REQ->method('GET'); $res = $UA->request($REQ); $content = $res->content(); my $io = new IO::String($content); my @mesgArr; while (<$io>) { if($_ =~ /\/ym\/ShowLetter/) { if($_ =~ /MsgId=([^\&]+)\&/) { print "$1\n"; push(@mesgArr, $1); } } } for $msgID (@mesgArr) { my $wholemail = ''; $REQ->uri("http://us.f134.mail.yahoo.com/ym/ShowLetter?box=Inbox&MsgId=$msgI D&Search=&PRINT=1&YY=42901&order=down&sort=date&pos=0&head=f"); print " Downloading $msgID: starting\n"; $REQ->method('GET'); $res = $UA->request($REQ); $content = $res->content(); my $skip = 1; $p = new HTML::SimpleParse( $content ); foreach ($p->tree) { if($_->{type} eq 'text') { my $print = unescape($_->{content}); my $match = $print; $match =~ s/\s+//g; if($match eq "" && $skip == 1) { next; } else { $skip = 0; } $wholemail .= $print if(defined($print) && $print ne ""); } } sendMail($fromaddr, $toaddr, $wholemail); print " Downloading $msgID: done\n"; } } } sub sendMail { my($fromUser, $destinations, $message) = @_; my($error); # This is not really appropriate for an argument, I think. my($server) = ("localhost"); my($fromDomain) = ($fromdomain); ######################################### # Establish a connection to the specified # SMTP server. Note that this also specifies # the domain from which we are connecting. # my($smtp); if ($fromDomain =~ /^\s*$/) { $smtp = Net::SMTP->new($server); } else { $smtp = Net::SMTP->new($server, Hello=>$fromDomain); } if (!defined($smtp)) { $error = "VirtualMail: Unable to connect to server \"$server\""; return($error); } $smtp->debug(0); # Indicate sender $smtp->mail($fromUser); # Indicate destination(s) my($destination); my (@destinations) = split(',', $destinations); for $destination (@destinations) { $smtp->recipient($destination); } $smtp->data(); # Start the message itself ######################################## # Message Body Stuff # $smtp->datasend($message); $smtp->dataend(); # End message if (!$smtp->quit()) { $error = "Unable to send the message to server $server"; } return($error); } _______________________________________________ linux-india-help mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/linux-india-help
