You may want to try it using an AJAX call and a button:
<?php
echo '<script type="text/javascript">';
echo 'var url = "http://mail.mydomain.com/";';
echo 'var params = "_user=". $_SESSION[\'username\'] ."&_pass=". $_SESSION[\'password\'] ."&_action=login";';
echo 'function LoginRC() {';
echo ' http.open("POST", url, true);';
echo ' //Send the proper header infomation along with the request';
echo ' http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");';
echo ' http.setRequestHeader("Content-length", params.length);';
echo ' http.setRequestHeader("Connection", "close");';
echo ' http.onreadystatechange = handler;';
echo ' http.send(params);';
echo '}';
echo '</script>';
<SNIP>
echo '<input type="button" value="Webmail" onclick="LoginRC()" />'
?>
The above code is not tested, but based on something I've found on the internet. Keep also in mind to use the right session variables.