You already have a complete email viewer built into cpanel, so why not take advantage of it? Use the following code to determine how many unread emails you have in your inbox as well as generate a link that will open your webmail without having to type your username/password:
$emailAddress = 'email@domain.com'; // Full email address
$emailPassword = 'yourpassword'; // Email password
$domainURL = 'domain.com'; // Your websites domain
$useHTTPS = true; // Depending on how your cpanel is set up, you may be using a secure connection and you may not be. Change this from true to false as needed for your situation
/* BEGIN MESSAGE COUNT CODE */
$inbox = imap_open('{'.$domainURL.':143/notls}INBOX',$emailAddress,$emailPassword) or die('Cannot connect to domain:' . imap_last_error());
$oResult = imap_search($inbox, 'UNSEEN');
if(empty($oResult))
$nMsgCount = 0;
else
$nMsgCount = count($oResult);
imap_close($inbox);
echo('<p>You have '.$nMsgCount.' unread messages.</p>');
/* END MESSAGE COUNT CODE */
echo('<a href="http'.($useHTTPS ? 's' : '').'://'.$domainURL.':'.($useHTTPS ? '2096' : '2095').'/login/?user='.$emailAddress.'&pass='.$emailPassword.'&failurl=http://'.$domainURL.'" target="_blank">Click here to open your inbox.</a>');
Of course, it is not the best practice to store your passwords in plaintext so you may want to come up with a solution for encrypting these, but you can use this example to get started.
Also, you need to have php_imap.dll enabled in php for the count of messages code to work. If you do not want to or cannot enable this, then you can remove the code between the MESSAGE COUNT CODE. The direct link to your webmail should work for any cpanel instance.