Subject: | fix some warnings + sending mails no longer works |
I had to patch a few things to hush up a couple of warnings with this
module.
Also, sending of mails through the module no longer works, at least for
me. It looks like HTML::Form fails to extract the <button
name="send(top|bottom)" ...> from the page for some reason, possibly
Javascript related.
I'm able to use the module intermittently - it will work for a while and
then I'll get ...
Select Folder failed on Folder Stats Retrieval: Not Found - trying to
get
https://edit.yahoo.com/config/Folders?.redir_from=LOGIN&.redir_from=REGISTRATION
Not sure if you're even using this any more but I figure it's worth a shot.
Simon
Subject: | mailclientyahoo.patch |
diff -urb MailClientYahoo-1.0/lib/Mail/Client/Yahoo.pm MailClientYahoo-new/lib/Mail/Client/Yahoo.pm
--- MailClientYahoo-1.0/lib/Mail/Client/Yahoo.pm 2004-05-11 23:12:31.000000000 +0100
+++ MailClientYahoo-new/lib/Mail/Client/Yahoo.pm 2006-03-28 15:28:40.000000000 +0100
@@ -2,6 +2,7 @@
use 5.006;
our $VERSION = 1.0;
+use Carp qw(croak);
#***** Interface *****#
@@ -40,7 +41,7 @@
slogin => 'https://login.yahoo.com/config/login?.src=ym',
logout => 'Logout',
folders => 'Folders',
- box => 'ShowFolder?sort=date&order=up&box=%s',
+ box => 'ShowFolder?sort=date&order=up&rb=%s',
msghead => 'ShowLetter?bodyPart=HEADER&box=%s&MsgId=%s',
msgbody => 'ShowLetter?bodyPart=TEXT&box=%s&MsgId=%s',
message => 'ShowLetter?box=%s&MsgId=%s',
@@ -72,7 +73,7 @@
save_value => 'yes',
attach_field => 'ATT',
attach_value => '1',
- send_button => 'SEND',
+ send_button => qr/Send/i,
send_error => qr/class="errmsg"/i,
attach_form => 'Attachments',
@@ -130,8 +131,8 @@
$self->{error} = sub {
my $msg = $self->{mech}->res->message;
$msg = shift()."\n" if $msg =~ /^OK/;
- ($args{error} || sub { die @_ })->(
- "$self->{phase} failed on $self->{step}: $msg"
+ ($args{error} || sub { croak @_ })->(
+ "$self->{phase} failed on $self->{step}: $msg - trying to get ". $self->{mech}->res()->request()->uri
);
};
@@ -163,6 +164,8 @@
$mech->get($1);
}
+
+
$self->{step} = 'Login';
if($mech->content =~ $Patterns{bad_user}) {
$self->error("Invalid username");
@@ -181,7 +184,9 @@
$self->{phase} = 'Logout';
$self->{step} = 'Logout Submission';
+ if (defined $self->{mech}) {
$self->{mech}->get($URLs{logout});
+ }
undef $self->{mech};
%$self = ();
@@ -193,16 +198,21 @@
sub _fetch_folder_stats {
my $self = shift;
+
$self->{step} = 'Folder Stats Retrieval';
+
$self->{mech}->get($URLs{folders});
+ #print STDERR $self->{mech}->res()->request()->uri;
+
my @stats = keys %{$Patterns{folder_stats}};
my @cols = @{$Patterns{folder_stats}}{@stats};
my $te = new HTML::TableExtract(headers => [@cols], keep_html => 1);
$te->parse($self->{mech}->content);
+
foreach my $row ($te->rows) {
my %stats;
@stats{@stats} = @$row;
@@ -226,7 +236,7 @@
my $self = shift;
my $name = shift;
- return if $name eq $self->{current_folder};
+ return if defined $self->{current_folder} && $name eq $self->{current_folder};
$self->{phase} = 'Select Folder';
@@ -427,6 +437,7 @@
$self->{step} = 'Form Retrieval';
$mech->get($URLs{sendmsg});
+
if($args{attach}) {
$self->{step} = 'Attach Files';
$mech->submit_form(
@@ -466,6 +477,11 @@
$cb->value($Patterns{html_value});
}
+ #die $mech->content;
+ use Data::Dumper;
+ #foreach my $f ($mech->forms) {
+ # print STDERR $f->dump;
+ # }
$mech->submit_form(
form_name => $Patterns{send_form},
fields => {
@@ -485,9 +501,12 @@
) : ()
),
},
- button => $Patterns{send_button},
+ #button => $Patterns{send_button},
);
+ $mech->click($Patterns{send_button});
+
+
if($mech->response->as_string() =~ $Patterns{send_error}) {
$self->error('Error sending message');
}
Only in MailClientYahoo-new: test