php-doc-en/reference/imap/functions/imap-open.xml
Markus Fischer 2d23ddfe59 - Sync most protos with current source.
- Move alised documented to their real function name and document what an
  alias is.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@99005 c90b9560-bf6c-de11-be94-00142212c4b1
2002-10-09 14:55:05 +00:00

165 lines
5.1 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/imap.xml, last change in rev 1.2 -->
<refentry id="function.imap-open">
<refnamediv>
<refname>imap_open</refname>
<refpurpose>Open an IMAP stream to a mailbox</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>resource</type><methodname>imap_open</methodname>
<methodparam><type>string</type><parameter>mailbox</parameter></methodparam>
<methodparam><type>string</type><parameter>username</parameter></methodparam>
<methodparam><type>string</type><parameter>password</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter></methodparam>
</methodsynopsis>
<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, but some functions and features are only 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, an optional port
(prefixed by ':'), and an optional protocol specification (prefixed
by '/'). The server part is mandatory in all mailbox
parameters. Mailbox 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">
<![CDATA[
$mbox = imap_open ("{localhost:143}INBOX", "user_id", "password");
]]>
</programlisting>
</informalexample>
To connect to a POP3 server on port 110 on the local server, use:
<informalexample>
<programlisting role="php">
<![CDATA[
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");
]]>
</programlisting>
</informalexample>
To connect to an SSL IMAP or POP3 server, add /ssl after the protocol
specification:
<informalexample>
<programlisting role="php">
<![CDATA[
$mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password");
]]>
</programlisting>
</informalexample>
To connect to an SSL IMAP or POP3 server with a self-signed
certificate, add /ssl/novalidate-cert after the protocol specification:
<informalexample>
<programlisting role="php">
<![CDATA[
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password");
]]>
</programlisting>
</informalexample>
To connect to an NNTP server on port 119 on the local server, use:
<informalexample>
<programlisting role="php">
<![CDATA[
$nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");
]]>
</programlisting>
</informalexample>
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>
<example>
<title><function>imap_open</function> example</title>
<programlisting role="php">
<![CDATA[
$mbox = imap_open ("{your.imap.host:143}", "username", "password");
echo "<p><h1>Mailboxes</h1>\n";
$folders = imap_listmailbox ($mbox, "{your.imap.host:143}", "*");
if ($folders == false) {
echo "Call failed<br>\n";
} else {
while (list ($key, $val) = each ($folders)) {
echo $val."<br>\n";
}
}
echo "<p><h1>Headers in INBOX</h1>\n";
$headers = imap_headers ($mbox);
if ($headers == false) {
echo "Call failed<br>\n";
} else {
while (list ($key,$val) = each ($headers)) {
echo $val."<br>\n";
}
}
imap_close($mbox);
]]>
</programlisting>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->