imap_last_error

This function returns the last IMAP error (if any) that occurred during this page request (PHP 3 >= 3.0.12, PHP 4, PHP 5)
string imap_last_error ( )

This function returns the full text of the last IMAP error message that occurred on the current page. The error stack is untouched; calling imap_last_error() subsequently, with no intervening errors, will return the same error.

See also: imap_errors().