The imap_num_recent function returns the number of recent messages in the current
mailbox.
<?
$mailbox = imap_open("{mail.server.com}INBOX",
"leon", "password");
print("Number of Messages: ".
imap_num_msg($mailbox));
imap_close($mailbox);
?>
integer imap_open(string mailbox, string username, string
password, integer flags)
Use imap_open to begin a connection to a mail server. The mailbox argument is
usually formed by adding a hostname to the beginning of the mailbox. The hostname is
enclosed in curly braces. Adding /pop3 causes the imap_open function to connect to
a POP server instead of an IMAP server. Adding /nntp allows you to connect to a
usenet server. You may also specify a port number, using a colon to separate it from the
hostname. A stream identifier is returned. Use this identifier with the IMAP functions
that require a stream. The optional flags argument is a bitfield that uses the constants
listed in Table 14.8.
Table 14.8. Constants Used by imap_open
Constant Description
CL_EXPUNGE (^) Expunge mailboxes automatically on close.
OP_ANONYMOUS (^) Don't use .newsrc file if connecting to an NNTP server.
OP_DEBUG (^) Debug protocol negotiations
OP_EXPUNGE (^) Expunge connections.
OP_HALFOPEN (^) Open connection, but not a mailbox.
OP_PROTOTYPE (^) Return driver prototype.
OP_READONLY (^) Open in read-only mode.
OP_SECURE (^) Don't do nonsecure authentication.
OP_SHORTCACHE (^) Use short caching.
OP_SILENT (^) Don't pass up events.
<?
//connect to a normal IMAP server
$mailbox = imap_open("{mail.server.com:143}INBOX",
"leon", "password");
//connect to a POP3 server