diff --git a/functions/imap.xml b/functions/imap.xml
index 617742149b..5a7ccdc4e6 100644
--- a/functions/imap.xml
+++ b/functions/imap.xml
@@ -117,8 +117,7 @@
imap_append example
-
-
$stream = imap_open("{your.imap.host}INBOX.Drafts","username", "password");
$check = imap_check($stream);
@@ -136,7 +135,6 @@ $check = imap_check($stream);
print "Msg Count after append : ". $check->Nmsgs."\n";
imap_close($stream);
-?>
@@ -162,6 +160,29 @@ imap_close($stream);
See also imap_binary.
+
+
+ imap_mailboxmsginfo example
+
+$mbox = imap_open("{your.imap.host}INBOX","username", "password")
+ || die("can't connect: ".imap_last_error());
+
+$check = imap_mailboxmsginfo($mbox);
+
+if($check) {
+ print "Date: " . $check->Date ."<br>\n" ;
+ print "Driver: " . $check->Driver ."<br>\n" ;
+ print "Mailbox: " . $check->Mailbox ."<br>\n" ;
+ print "Messages: ". $check->Nmsgs ."<br>\n" ;
+ print "Recent: " . $check->Recent ."<br>\n" ;
+ print "Size: " . $check->Size ."<br>\n" ;
+} else
+ print "imap_check() failed: ".imap_lasterror(). "<br>\n";
+
+imap_close($mbox);
+
+
+
@@ -307,6 +328,56 @@ imap_close($stream);
imap_open for the format
of mbox names.
+
+
+ imap_createmailbox example
+
+$mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
+ || die("can't connect: ".imap_last_error());
+
+$name1 = "phpnewbox";
+$name2 = imap_utf7_encode("phpnewböx");
+
+$newname = $name1;
+
+echo "Newname will be '$name1'<br>\n";
+
+# we will now create a new mailbox "phptestbox" in your inbox folder,
+# check its status after creation and finaly remove it to restore
+# your inbox to its initial state
+if(@imap_createmailbox($mbox,imap_utf7_encode("{your.imap.host}INBOX.$newname"))) {
+ $status = @imap_status($mbox,"{your.imap.host}INBOX.$newname",SA_ALL);
+ if($status) {
+ print("your new mailbox '$name1' has the following status:<br>\n");
+ print("Messages: ". $status->messages )."<br>\n";
+ print("Recent: ". $status->recent )."<br>\n";
+ print("Unseen: ". $status->unseen )."<br>\n";
+ print("UIDnext: ". $status->uidnext )."<br>\n";
+ print("UIDvalidity:". $status->uidvalidity)."<br>\n";
+
+ if(imap_renamemailbox($mbox,"{your.imap.host}INBOX.$newname","{your.imap.host}INBOX.$name2")) {
+ echo "renamed new mailbox from '$name1' to '$name2'<br>\n";
+ $newname=$name2;
+ } else {
+ print "imap_renamemailbox on new mailbox failed: ".imap_last_error()."<br>\n";
+ }
+ } else {
+ print "imap_status on new mailbox failed: ".imap_last_error()."<br>\n";
+ }
+ if(@imap_deletemailbox($mbox,"{your.imap.host}INBOX.$newname")) {
+ print "new mailbox removed to restore initial state<br>\n";
+ } else {
+ print "imap_deletemailbox on new mailbox failed: ".implode("<br>\n",imap_errors())."<br>\n";
+ }
+
+} else {
+ print "could not create new mailbox: ".implode("<br>\n",imap_errors())."<br>\n";
+}
+
+imap_close($mbox);
+
+
+
@@ -787,6 +858,25 @@ fetchsubject (subject line formatted to fit subjectlength
See imap_getmailboxes for a description
of ref and pattern.
+
+
+ imap_getmailboxes example
+
+$mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
+ || die("can't connect: ".imap_last_error());
+
+$list = imap_listmailbox($mbox,"{your.imap.host}","*");
+if(is_array($list)) {
+ reset($list);
+ while (list($key, $val) = each($list))
+ print imap_utf7_decode($val)."<br>\n";
+} else
+ print "imap_listmailbox failed: ".imap_last_error()."\n";
+
+imap_close($mbox);
+
+
+
@@ -841,8 +931,13 @@ fetchsubject (subject line formatted to fit subjectlength
- ref should normally be just the IMAP
- server, in the form: {imap_server:imap_port}, and
+ Mailbox names containing international Characters outside the
+ printable ASCII range will be encoded and may be decoded by
+ imap_utf7_decode.
+
+
+ ref should normally be just the server
+ specification as described in imap_open, and
pattern specifies where in the mailbox
hierarchy to start searching. If you want all mailboxes, pass
'*' for pattern.
@@ -858,6 +953,30 @@ fetchsubject (subject line formatted to fit subjectlength
in the ~/mail directory, but none in subfolders of that
directory.
+
+
+ imap_getmailboxes example
+
+$mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
+ || die("can't connect: ".imap_last_error());
+
+$list = imap_getmailboxes($mbox,"{your.imap.host}","*");
+if(is_array($list)) {
+ reset($list);
+ while (list($key, $val) = each($list))
+ {
+ print "($key) ";
+ print imap_utf7_decode($val->name).",";
+ print "'".$val->delimiter."',";
+ print $val->attributes."<br>\n";
+ }
+} else
+ print "imap_getmailboxes failed: ".imap_last_error()."\n";
+
+imap_close($mbox);
+
+
+
@@ -1042,7 +1161,49 @@ fetchsubject (subject line formatted to fit subjectlength
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
+ servers, but some functions and features are not available
+ on IMAP servers.
+
+
+ A mailbox name consists of a server part and a mailbox path on
+ this server. The special name INBOX stands for the current users
+ personal mailbox. The server part, which is enclosed in '{' and
+ '}', consists of the servers name or ip address, a protocol
+ secification (beginning with '/') and an optional port specifier
+ beginnung with ':'. The server part is mandatory in all mailbox
+ parameters. Mailbos names that contain international characters
+ besides those in the printable ASCII space have to be encoded
+ with imap_utf7_encode.
+
+
+ The options are a bit mask with one or more of the following:
+
+
+
+ OP_READONLY - Open mailbox read-only
+
+
+
+
+ OP_ANONYMOUS - Dont use or update a
+ .newsrc for news (NNTP only)
+
+
+
+
+ OP_HALFOPEN - For IMAP and NNTP names, open a connection but
+ dont open a mailbox
+
+
+
+
+ CL_EXPUNGE - Expunge mailbox automatically upon mailbox close
+
+
+
+
+
+ To connect to an IMAP server running on port 143 on the
local machine, do the following:
@@ -1064,33 +1225,6 @@ $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:
-
-
-
- OP_READONLY - Open mailbox read-only
-
-
-
-
- OP_ANONYMOUS - Dont use or update a
- .newsrc for news (NNTP only)
-
-
-
-
- OP_HALFOPEN - For IMAP and NNTP names, open a connection but
- dont open a mailbox
-
-
-
-
- CL_EXPUNGE - Expunge mailbox automatically upon mailbox close
-
-
-
-
imap_open example
@@ -1101,7 +1235,7 @@ echo "<p><h1>Mailboxes</h1>\n";
$folders = imap_listmailbox ($mbox, "{your.imap.host:143}", "*");
if ($folders == false) {
- echo "Call failed<br>\n";
+ echo "Call failed<br>\n";
} else {
while (list ($key, $val) = each ($folders)) {
echo $val."<br>\n";
@@ -1492,6 +1626,14 @@ imap_close($mbox);
RFC822
given the mailbox, host, and personal info.
+
+
+ imap_rfc822_write_address example
+
+print imap_rfc822_write_address("hartmut","cvs.php.net","Hartmut Holzgraefe")."\n";
+
+
+
@@ -1503,7 +1645,7 @@ imap_close($mbox);
Description
- string
+ array
imap_rfc822_parse_adrlist
string address
@@ -1513,17 +1655,49 @@ imap_close($mbox);
This function parses the address string as defined in
RFC822 and
for each address, returns an array of objects.
- The 4 objects are:
+ The objects properties are:
-
-
-mailbox - the mailbox name (username)
-host - the host name
-personal - the personal name
-adl - at domain source route
-
-
+
+
+
+ mailbox - the mailbox name (username)
+
+
+
+
+ host - the host name
+
+
+
+
+ personal - the personal name
+
+
+
+
+ adl - at domain source route
+
+
+
+
+
+
+ imap_rfc822_parse_adrlist example
+
+$address_string = "Hartmut Holzgraefe <hartmut@cvs.php.net>, postmaster@somedomain.net, root";
+$address_array = imap_rfc822_parse_adrlist($address_string,"somedomain.net");
+if(! is_array($address_array)) die("somethings wrong\n");
+
+reset($address_array);
+while(list($key,$val)=each($address_array)){
+ print "mailbox : ".$val->mailbox."<br>\n";
+ print "host : ".$val->host."<br>\n";
+ print "personal: ".$val->personal."<br>\n";
+ print "adl : ".$val->adl."<p>\n";
+}
+
+
@@ -1560,7 +1734,22 @@ ST_UID The sequence argument contains UIDs instead of
-
+
+
+ imap_setflag_full example
+
+$mbox = imap_open("{your.imap.host:143}","username","password")
+ || die("can't connect: ".imap_last_error());
+
+$status = imap_setflag_full($mbox,"2,5","\\Seen \\Flagged");
+
+print gettype($status)."\n";
+print $status."\n";
+
+imap_close($mbox);
+
+
+
@@ -2028,6 +2217,27 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
status->flags is also set, which contains a bitmask which can be
checked against any of the above constants.
+
+
+ imap_status example
+
+$mbox = imap_open("{your.imap.host}","username","password",OP_HALFOPEN)
+ || die("can't connect: ".imap_last_error());
+
+$status = imap_status($mbox,"{your.imap.host}INBOX",SA_ALL);
+if($status) {
+ print("Messages: ". $status->messages )."<br>\n";
+ print("Recent: ". $status->recent )."<br>\n";
+ print("Unseen: ". $status->unseen )."<br>\n";
+ print("UIDnext: ". $status->uidnext )."<br>\n";
+ print("UIDvalidity:". $status->uidvalidity)."<br>\n";
+} else
+ print "imap_status failed: ".imap_lasterror()."\n";
+
+imap_close($mbox);
+
+
+
@@ -2049,10 +2259,12 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
Returns the decoded 8bit data, or false if the input string was
- not valid modified UTF-7. The modified UTF-7 encoding is defined in
- RFC 2060, section 5.1.3
- (original UTF-7 was defned in
- RFC1642).
+ not valid modified UTF-7. This function is needed to decode
+ mailbox names that contain international characters outside of
+ the printable ASCII range. The modified UTF-7 encoding is defined
+ in RFC 2060, section
+ 5.1.3 (original UTF-7 was defned in RFC1642).
@@ -2071,11 +2283,13 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
string data
- Converts 8bit data to modified
- UTF-7 text. The modified UTF-7 encoding is defined in
- RFC 2060, section 5.1.3
- (original UTF-7 was defned in
- RFC1642).
+ Converts 8bit data to modified UTF-7
+ text. This is needed to encode mailbox names that contain
+ international characters outside of the printable ASCII
+ range. The modified UTF-7 encoding is defined in RFC 2060, section 5.1.3
+ (original UTF-7 was defned in RFC1642).
Returns the modified UTF-7 text.
@@ -2117,11 +2331,15 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
array imap_fetch_overview
int imap_stream
string sequence
+ int flags
- This function fetches a mail header and returns an overview of
- its contents. It will return an array of objects describing one
- message header each:
+ This function fetches mail headers for the given
+ sequence and returns an overview of their
+ contents. sequence will contain a sequence
+ of message indices or UIDs, if flags
+ contains FT_UID. The returned value is an array of objects
+ describing one message header each:
@@ -2195,6 +2413,29 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
+
+
+ imap_fetch_overview example
+
+$mbox = imap_open("{your.imap.host:143}","username","password")
+ || die("can't connect: ".imap_last_error());
+
+$overview = imap_fetch_overview($mbox,"2,4:6",0);
+
+if(is_array($overview)) {
+ reset($overview);
+ while( list($key,$val) = each($overview)) {
+ print $val->msgno
+ . " - " . $val->date
+ . " - " . $val->subject
+ . "\n";
+ }
+}
+
+imap_close($mbox);
+
+
+