TechniqueUse the imap_open() function, which enables you to open a stream to a POP, NNTP, or IMAP server. To open a connection to an IMAP server, do the following:  <?php $mh = imap_open("{servername.com:143}INBOX", $user, $pass); ?>  To open a connection to a POP server, simply specify it in the syntax of the first argument:  <?php $mh = imap_open("{servername.com/pop3:110}INBOX", $user, $pass); ?>  The same thing applies when accessing an NNTP server:  <?php $nh = imap_open("{servername.com/nntp:119}comp.lang.perl.misc",                 $username, $password ); ?>  CommentsThe imap_open() function takes as its first argument the mailbox name. The server part of the mailbox name , enclosed in { and } , consists of the server name, a protocol specification that is separated from the server name with / , and an optional port specifier beginning with : . The second and third arguments to imap_open() are your username and passwords, respectively. imap_open() is the only place where you need to distinguish between server types (that is, nntp or pop3 ). You can manipulate the stream returned by imap_open() with any of the appropriate imap_* functions. Of course, because of the difference in the types of programs, some functions will not work with different server types.  |