hey perl monks, I am trying to login to a webmail server using the perl LWP::User Agent. This works well but before I can access the INBOX I am redirected back to the login page. Here is what I have so far:

use strict; use LWP; use LWP::Debug qw(+); my $url = 'https://www.a-university.edu/horde/imp/'; my $url_redi = $url . "redirect.php"; # there is a problem with the server's certificate, # but this is not the issue here my $ua = LWP::UserAgent->new( ssl_opts => { SSL_verify_mode => 'SSL_VERIFY_NONE'}); my $form = $ua->get($url_redi) or die "couldn't fetch $url_redi"; $form->is_success() or die $form->message(); # extract cookie my $formcont = $form->content(); my $sessionid; if ($formcont =~ m/Horde=(.*?)" method/s) { $sessionid = $1; } # submit user name and password # all other items required as shown by the web page source code my $response = $ua->post( $url . "?Horde=" . $sessionid, [ 'imapuser' => 'jobro', 'pass' => 'verysecret', 'actionID' => '105', 'url' => '', 'mailbox' => 'INBOX', 'server' => 'hardy.a-university.edu', 'port' => '143', 'namespace' => '', 'maildomain' => 'a-university.edu', 'protocol' => 'imap/notls', 'realm' => 'a-university.edu', 'folders' => 'mail/', 'new_lang' => 'en_US', 'button' => 'Log in' ] ); # at his point the # print $response->as_string(); # is as expected # now the server sends (as part of the http header) # a location for redirection # (I know that I can follow redirections automatically, but this # leads to the same problem) # so I read off the address and try to get this page my $inbox = $ua->get( $url . "mailbox.php?Horde=" . $sessionid, [ 'actionID' => '149', 'mailbox' => 'INBOX' ] ); # but now I am back to the login page :(

(I asked the same question on stack overflow, but no result)


In reply to perl LWP::User Agent credentials ignored on redirect by jobro

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.