There is no complex code, the error is at the elementary stage
Code:
$inbox=imap_open ("{imap.gmail.com:993/imap/ssl}Inbox", "username@gmail.com", "password")
or die("Error: " . imap_last_error());
You execute this code with your IMAP enabled gmail account username, pass. If it fails to connect, error will be shown else nothing.