imap_open -- Open an IMAP stream to a mailbox


int imap_open(string mailbox, string username, string password, int flags);

Returns an IMAP stream on success and false on error. This function can also be used to open streams to POP3 and NNTP servers. To connect to an IMAP server running on port 143 on the local machine, do the following:

$mbox = imap_open("{localhost:143}INBOX","user_id","password");

To connect to a POP3 server on port 110 on the local server, use:

$mbox = imap_open("{localhost/pop3:110}INBOX","user_id","password");

To connect to an NNTP server on port 119 on the local server, use:

$nntp = imap_open("{localhost/nntp:119}comp.test","","");

To connect to a remote server replace "localhost" with the name or the IP address of the server you want to connect to.

The options are a bit mask with one or more of the following: