What are the correct syntax and parameters for using imap_open in PHP to connect to an IMAP server?

To connect to an IMAP server using PHP, you need to use the imap_open function with the correct syntax and parameters. The correct syntax for imap_open is imap_open('{hostname:port/protocol}INBOX', 'username', 'password'). Make sure to replace 'hostname', 'port', 'protocol', 'username', and 'password' with the appropriate values for your IMAP server.

$hostname = '{mail.example.com:993/imap/ssl}';
$username = 'your_username';
$password = 'your_password';

$mailbox = imap_open($hostname, $username, $password);

if (!$mailbox) {
    die('Connection failed: ' . imap_last_error());
} else {
    echo 'Connected to IMAP server';
}