use WWW::Mechanize; use HTTP::Cookies; use Stream::Reader; $url="https://webmail.com/exchange"; my $username = "UserName"; my $password = "Password123"; my $mechanize = WWW::Mechanize->new(autocheck => 1); $mechanize->cookie_jar(HTTP::Cookies->new()); $mechanize->get($url); $mechanize->form_name('logonForm'); $mechanize->field(username => $username); $mechanize->field(password => $password); $mechanize->click(); $mechanize->get("https://webmail.com/exchange/username/Inbox/?Cmd=contents&Page=1"); my $page = $mechanize->content();