mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
more examples and minor corrections
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@21525 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
523173744b
commit
0d1a6ff2f2
1 changed files with 298 additions and 57 deletions
|
@ -117,8 +117,7 @@
|
|||
<para>
|
||||
<example>
|
||||
<title><function>imap_append</function> example</title>
|
||||
<programlisting>
|
||||
<?php
|
||||
<programlisting role="php">
|
||||
$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);
|
||||
?>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
@ -162,6 +160,29 @@ imap_close($stream);
|
|||
<para>
|
||||
See also <function>imap_binary</function>.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_mailboxmsginfo</function> example</title>
|
||||
<programlisting role="php">
|
||||
$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);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -307,6 +328,56 @@ imap_close($stream);
|
|||
<function>imap_open</function> for the format
|
||||
of <parameter>mbox</parameter> names.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_createmailbox</function> example</title>
|
||||
<programlisting>
|
||||
$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);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -787,6 +858,25 @@ fetchsubject (subject line formatted to fit <parameter>subjectlength</parameter>
|
|||
See <function>imap_getmailboxes</function> for a description
|
||||
of <parameter>ref</parameter> and <parameter>pattern</parameter>.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_getmailboxes</function> example</title>
|
||||
<programlisting role="php">
|
||||
$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);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -841,8 +931,13 @@ fetchsubject (subject line formatted to fit <parameter>subjectlength</parameter>
|
|||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
<parameter>ref</parameter> 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
|
||||
<function>imap_utf7_decode</function>.
|
||||
</para>
|
||||
<para>
|
||||
<parameter>ref</parameter> should normally be just the server
|
||||
specification as described in <function>imap_open</function>, and
|
||||
<parameter>pattern</parameter> specifies where in the mailbox
|
||||
hierarchy to start searching. If you want all mailboxes, pass
|
||||
'*' for <parameter>pattern</parameter>.
|
||||
|
@ -858,6 +953,30 @@ fetchsubject (subject line formatted to fit <parameter>subjectlength</parameter>
|
|||
in the ~/mail directory, but none in subfolders of that
|
||||
directory.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_getmailboxes</function> example</title>
|
||||
<programlisting role="php">
|
||||
$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);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -1042,7 +1161,49 @@ fetchsubject (subject line formatted to fit <parameter>subjectlength</parameter>
|
|||
<para>
|
||||
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.
|
||||
</para>
|
||||
<para>
|
||||
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 <function>imap_utf7_encode</function>.
|
||||
</para>
|
||||
<para>
|
||||
The options are a bit mask with one or more of the following:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
OP_READONLY - Open mailbox read-only
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
OP_ANONYMOUS - Dont use or update a
|
||||
<filename>.newsrc</filename> for news (NNTP only)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
OP_HALFOPEN - For IMAP and NNTP names, open a connection but
|
||||
dont open a mailbox
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
CL_EXPUNGE - Expunge mailbox automatically upon mailbox close
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
To connect to an IMAP server running on port 143 on the
|
||||
local machine, do the following:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
|
@ -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.
|
||||
</para>
|
||||
<para>
|
||||
The options are a bit mask with one or more of the following:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
OP_READONLY - Open mailbox read-only
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
OP_ANONYMOUS - Dont use or update a
|
||||
<filename>.newsrc</filename> for news (NNTP only)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
OP_HALFOPEN - For IMAP and NNTP names, open a connection but
|
||||
dont open a mailbox
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
CL_EXPUNGE - Expunge mailbox automatically upon mailbox close
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_open</function> example</title>
|
||||
|
@ -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);
|
|||
<ulink url="&url.rfc;/rfc822.html">RFC822</ulink>
|
||||
given the mailbox, host, and personal info.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_rfc822_write_address</function> example</title>
|
||||
<programlisting role="php">
|
||||
print imap_rfc822_write_address("hartmut","cvs.php.net","Hartmut Holzgraefe")."\n";
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -1503,7 +1645,7 @@ imap_close($mbox);
|
|||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcdef>string
|
||||
<funcdef>array
|
||||
<function>imap_rfc822_parse_adrlist</function>
|
||||
</funcdef>
|
||||
<paramdef>string <parameter>address</parameter></paramdef>
|
||||
|
@ -1513,17 +1655,49 @@ imap_close($mbox);
|
|||
This function parses the address string as defined in
|
||||
<ulink url="&url.rfc;/rfc822.html">RFC822</ulink> and
|
||||
for each address, returns an array of objects.
|
||||
The 4 objects are:
|
||||
The objects properties are:
|
||||
</para>
|
||||
<para>
|
||||
<informalexample>
|
||||
<literallayout>
|
||||
mailbox - the mailbox name (username)
|
||||
host - the host name
|
||||
personal - the personal name
|
||||
adl - at domain source route
|
||||
</literallayout>
|
||||
</informalexample>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
mailbox - the mailbox name (username)
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
host - the host name
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
personal - the personal name
|
||||
</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
adl - at domain source route
|
||||
</simpara>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_rfc822_parse_adrlist</function> example</title>
|
||||
<programlisting role="php">
|
||||
$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";
|
||||
}
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -1560,7 +1734,22 @@ ST_UID The sequence argument contains UIDs instead of
|
|||
</literallayout>
|
||||
</informalexample>
|
||||
</para>
|
||||
</refsect1>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_setflag_full</function> example</title>
|
||||
<programlisting role="php">
|
||||
$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);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para> </refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.imap-clearflag-full">
|
||||
|
@ -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.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_status</function> example</title>
|
||||
<programlisting role="php">
|
||||
$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);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -2049,10 +2259,12 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
|
|||
</para>
|
||||
<para>
|
||||
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
|
||||
<ulink url="&url.rfc;/rfc2060.html">RFC 2060</ulink>, section 5.1.3
|
||||
(original UTF-7 was defned in
|
||||
<ulink url="&url.rfc;/rfc1642.html">RFC1642</ulink>).
|
||||
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 <ulink url="&url.rfc;/rfc2060.html">RFC 2060</ulink>, section
|
||||
5.1.3 (original UTF-7 was defned in <ulink
|
||||
url="&url.rfc;/rfc1642.html">RFC1642</ulink>).
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
@ -2071,11 +2283,13 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
|
|||
<paramdef>string <parameter>data</parameter></paramdef>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Converts 8bit <parameter>data</parameter> to modified
|
||||
UTF-7 text. The modified UTF-7 encoding is defined in
|
||||
<ulink url="&url.rfc;/rfc2060.html">RFC 2060</ulink>, section 5.1.3
|
||||
(original UTF-7 was defned in
|
||||
<ulink url="&url.rfc;/rfc1642.html">RFC1642</ulink>).
|
||||
Converts 8bit <parameter>data</parameter> 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 <ulink
|
||||
url="&url.rfc;/rfc2060.html">RFC 2060</ulink>, section 5.1.3
|
||||
(original UTF-7 was defned in <ulink
|
||||
url="&url.rfc;/rfc1642.html">RFC1642</ulink>).
|
||||
</para>
|
||||
<para>
|
||||
Returns the modified UTF-7 text.
|
||||
|
@ -2117,11 +2331,15 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
|
|||
<funcdef>array <function>imap_fetch_overview</function></funcdef>
|
||||
<paramdef>int <parameter>imap_stream</parameter></paramdef>
|
||||
<paramdef>string <parameter>sequence</parameter></paramdef>
|
||||
<paramdef>int <parameter><optional>flags</optional></parameter></paramdef>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
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
|
||||
<parameter>sequence</parameter> and returns an overview of their
|
||||
contents. <parameter>sequence</parameter> will contain a sequence
|
||||
of message indices or UIDs, if <parameter>flags</parameter>
|
||||
contains FT_UID. The returned value is an array of objects
|
||||
describing one message header each:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
|
@ -2195,6 +2413,29 @@ FT_PREFETCHTEXT The RFC822.TEXT should be pre-fetched at the
|
|||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>imap_fetch_overview</function> example</title>
|
||||
<programlisting role="php">
|
||||
$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);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
|
Loading…
Reference in a new issue