When deleting user account(s) from IMAP server don't forget to put full server name and port. Also need to be logged as IMAP admin and set ACL.
This worked for Cyrus:
<?php
$cyrusadmin_username="cyrus";
$cyrusadmin_password="cyruspassword";
$cyrus_serverip="fellowship.ring.net";
$username="frodoBaggins";
$mbox=imap_open("{".$serverip.":143}",$cyrusadmin_username, $cyrusadmin_password, OP_HALFOPEN)
or die('IMAP Could not connect because '.imap_last_error());
imap_setacl ($mbox, "user.".$username, $cyrusadmin_username, "lrswipcda")
or die('Could not setacl on mailbox');
imap_deletemailbox($mbox,"{".$serverip.":143}user.".$username)
or die('Could not delete mailbox');
?>