Okay thank you that fixed most of the problems.
This is my code:
class getunread extends rcube_plugin{
public $task='mail';
function init(){
$this->register_action('plugin.unreadmessage', array($this, 'unreadmessage_handler'));
}
function unreadmessage_handler(){
$rcmail = rcmail::get_instance();
$count=$rcmail->imap->messagecount('INBOX', 'UNSEEN');
die($count);
}
}
However, the page is just blank. And it didn't break the page because I was able to write some stuff after.