1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 298918 $ -->
<refentry xml:id="function.imap-open" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>imap_open</refname>
<refpurpose>Open an <acronym>IMAP</acronym> stream to a mailbox</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<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><initializer>NIL</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>n_retries</parameter><initializer>0</initializer></methodparam>
<methodparam choice="opt"><type>array</type><parameter>params</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Opens an <acronym>IMAP</acronym> stream to a <parameter>mailbox</parameter>.
</para>
<para>
This function can also be used to open streams to <acronym>POP3</acronym> and
<acronym>NNTP</acronym> servers, but some functions and features are only
available on <acronym>IMAP</acronym> servers.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>mailbox</parameter></term>
<listitem>
<para>
A mailbox name consists of a server and a mailbox path on this server.
The special name <literal>INBOX</literal> stands for the current users
personal mailbox. Mailbox names that contain international characters
besides those in the printable ASCII space have to be encoded width
<function>imap_utf7_encode</function>.
</para>
<para>
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 '/').
</para>
<para>
The server part is mandatory in all mailbox
parameters.
</para>
<para>
All names which start with <literal>{</literal> are remote names, and are
in the form <literal>"{" remote_system_name [":" port] [flags] "}"
[mailbox_name]</literal> where:
<itemizedlist>
<listitem>
<simpara>
<literal>remote_system_name</literal> - Internet domain name or
bracketed IP address of server.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>port</literal> - optional TCP port number, default is the
default port for that service
</simpara>
</listitem>
<listitem>
<simpara>
<literal>flags</literal> - optional flags, see following table.
</simpara>
</listitem>
<listitem>
<simpara>
<literal>mailbox_name</literal> - remote mailbox name, default is INBOX
</simpara>
</listitem>
</itemizedlist>
</para>
<para>
<table>
<title>Optional flags for names</title>
<tgroup cols="2">
<thead>
<row>
<entry>Flag</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>/service=</literal><emphasis>service</emphasis></entry>
<entry>mailbox access service, default is "imap"</entry>
</row>
<row>
<entry><literal>/user=</literal><emphasis>user</emphasis></entry>
<entry>remote user name for login on the server</entry>
</row>
<row>
<entry><literal>/authuser=</literal><emphasis>user</emphasis></entry>
<entry>remote authentication user; if specified this is the user name
whose password is used (e.g. administrator)</entry>
</row>
<row>
<entry><literal>/anonymous</literal></entry>
<entry>remote access as anonymous user</entry>
</row>
<row>
<entry><literal>/debug</literal></entry>
<entry>record protocol telemetry in application's debug log</entry>
</row>
<row>
<entry><literal>/secure</literal></entry>
<entry>do not transmit a plaintext password over the network</entry>
</row>
<row>
<entry><literal>/imap</literal>, <literal>/imap2</literal>,
<literal>/imap2bis</literal>, <literal>/imap4</literal>,
<literal>/imap4rev1</literal></entry>
<entry>equivalent to <literal>/service=imap</literal></entry>
</row>
<row>
<entry><literal>/pop3</literal></entry>
<entry>equivalent to <literal>/service=pop3</literal></entry>
</row>
<row>
<entry><literal>/nntp</literal></entry>
<entry>equivalent to <literal>/service=nntp</literal></entry>
</row>
<row>
<entry><literal>/norsh</literal></entry>
<entry>do not use rsh or ssh to establish a preauthenticated IMAP
session</entry>
</row>
<row>
<entry><literal>/ssl</literal></entry>
<entry>use the <literal>Secure Socket Layer</literal> to encrypt the session</entry>
</row>
<row>
<entry><literal>/validate-cert</literal></entry>
<entry>validate certificates from TLS/SSL server (this is the default
behavior)</entry>
</row>
<row>
<entry><literal>/novalidate-cert</literal></entry>
<entry>do not validate certificates from TLS/SSL server, needed if
server uses self-signed certificates</entry>
</row>
<row>
<entry><literal>/tls</literal></entry>
<entry>force use of <literal>start-TLS</literal> to encrypt the session, and reject
connection to servers that do not support it</entry>
</row>
<row>
<entry><literal>/notls</literal></entry>
<entry>do not do <literal>start-TLS</literal> to encrypt the session, even with servers
that support it</entry>
</row>
<row>
<entry><literal>/readonly</literal></entry>
<entry>request read-only mailbox open (IMAP only; ignored on NNTP, and
an error with SMTP and POP3)</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>username</parameter></term>
<listitem>
<para>
The user name
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>password</parameter></term>
<listitem>
<para>
The password associated with the <parameter>username</parameter>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
The <parameter>options</parameter> are a bit mask with one or more of
the following:
<itemizedlist>
<listitem>
<simpara>
<constant>OP_READONLY</constant> - Open mailbox read-only
</simpara>
</listitem>
<listitem>
<simpara>
<constant>OP_ANONYMOUS</constant> - Don't use or update a
<filename>.newsrc</filename> for news (NNTP only)
</simpara>
</listitem>
<listitem>
<simpara>
<constant>OP_HALFOPEN</constant> - For <acronym>IMAP</acronym>
and <acronym>NNTP</acronym> names, open a connection but
don't open a mailbox.
</simpara>
</listitem>
<listitem>
<simpara>
<constant>CL_EXPUNGE</constant> - Expunge mailbox automatically upon mailbox close
(see also <function>imap_delete</function> and
<function>imap_expunge</function>)
</simpara>
</listitem>
<listitem>
<simpara>
<constant>OP_DEBUG</constant> - Debug protocol negotiations
</simpara>
</listitem>
<listitem>
<simpara>
<constant>OP_SHORTCACHE</constant> - Short (<literal>elt</literal>-only) caching
</simpara>
</listitem>
<listitem>
<simpara>
<constant>OP_SILENT</constant> - Don't pass up events (internal use)
</simpara>
</listitem>
<listitem>
<simpara>
<constant>OP_PROTOTYPE</constant> - Return driver prototype
</simpara>
</listitem>
<listitem>
<simpara>
<constant>OP_SECURE</constant> - Don't do non-secure authentication
</simpara>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>n_retries</parameter></term>
<listitem>
<para>
Number of maximum connect attempts
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>params</parameter></term>
<listitem>
<para>
Connection parameters, the following (string) keys maybe used
to set one or more connection parameters:
<itemizedlist>
<listitem>
<simpara>
<literal>DISABLE_AUTHENTICATOR</literal> - Disable authentication properties
</simpara>
</listitem>
</itemizedlist>
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an IMAP stream on success or &false; on error.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.3.2</entry>
<entry><parameter>params</parameter> added</entry>
</row>
<row>
<entry>5.2.0</entry>
<entry><parameter>n_retries</parameter> added</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Different use of <function>imap_open</function></title>
<programlisting role="php">
<![CDATA[
<?php
// To connect to an IMAP server running on port 143 on the local machine,
// do the following:
$mbox = imap_open("{localhost:143}INBOX", "user_id", "password");
// To connect to a POP3 server on port 110 on the local server, use:
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");
// To connect to an SSL IMAP or POP3 server, add /ssl after the protocol
// specification:
$mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password");
// To connect to an SSL IMAP or POP3 server with a self-signed certificate,
// add /ssl/novalidate-cert after the protocol specification:
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "user_id", "password");
// To connect to an NNTP server on port 119 on the local server, use:
$nntp = imap_open ("{localhost:119/nntp}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.
?>
]]>
</programlisting>
</example>
<example>
<title><function>imap_open</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$mbox = imap_open("{imap.example.org:143}", "username", "password");
echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{imap.example.org:143}", "*");
if ($folders == false) {
echo "Call failed<br />\n";
} else {
foreach ($folders as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);
if ($headers == false) {
echo "Call failed<br />\n";
} else {
foreach ($headers as $val) {
echo $val . "<br />\n";
}
}
imap_close($mbox);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>imap_close</function></member>
</simplelist>
</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:"~/.phpdoc/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
-->
|