Um, you seem to be using the functional side of CGI (param), but you never call use CGI qw/:standard/;.
That aside, check out WWW::Mechanize (or some of the LWP libraries). It can send POST data directly to a form on a page (in your case, the login page of your webmail), which I what I think you are trying to do.