Files
php-doc-ru/reference/imap/functions/imap-createmailbox.xml
2023-12-23 21:34:40 +03:00

152 lines
5.4 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 34892f82742329af7e7b4b22be6ad21418fd9768 Maintainer: rjhdby Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.imap-createmailbox" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>imap_createmailbox</refname>
<refpurpose>Создаёт новый почтовый ящик</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>imap_createmailbox</methodname>
<methodparam><type>IMAP\Connection</type><parameter>imap</parameter></methodparam>
<methodparam><type>string</type><parameter>mailbox</parameter></methodparam>
</methodsynopsis>
<para>
Создаёт новый почтовый ящик, указанный в <parameter>mailbox</parameter>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&imap.imap-parameter.imap;
<varlistentry>
<term><parameter>mailbox</parameter></term>
<listitem>
<para>
Имя почтового ящика. Более подробно смотрите <function>imap_open</function>.
Имена почтовых ящиков, содержащие интернациональные символы должны быть
закодированы с помощью <function>imap_utf7_encode</function>.
</para>
&imap.mailboxname.insecure;
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&imap.changelog.imap-param;
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>imap_createmailbox</function></title>
<programlisting role="php">
<![CDATA[
<?php
$mbox = imap_open("{imap.example.org}", "username", "password", OP_HALFOPEN)
or die("не получилось подключиться: " . imap_last_error());
$name1 = "phpnewbox";
$name2 = imap_utf7_encode("phpnewböx"); // phpnewb&w7Y-x
$newname = $name1;
echo "Новым именем будет '$name1'<br />\n";
// теперь создадим новый ящик "phptestbox" в вашем входящем каталоге,
// проверим его статус и удалим, чтобы вернуть ваш каталог к первоначальному
// состоянию
if (@imap_createmailbox($mbox, imap_utf7_encode("{imap.example.org}INBOX.$newname"))) {
$status = @imap_status($mbox, "{imap.example.org}INBOX.$newname", SA_ALL);
if ($status) {
echo "ваш новый почтовый ящик называется '$name1' и имеет следующий статус:<br />\n";
echo "Сообщений: " . $status->messages . "<br />\n";
echo "Новых: " . $status->recent . "<br />\n";
echo "Непрочитанных: " . $status->unseen . "<br />\n";
echo "Следующий UID: " . $status->uidnext . "<br />\n";
echo "Корректность UID:" . $status->uidvalidity . "<br />\n";
if (imap_renamemailbox($mbox, "{imap.example.org}INBOX.$newname", "{imap.example.org}INBOX.$name2")) {
echo "переименуем новый ящик из '$name1' в '$name2'<br />\n";
$newname = $name2;
} else {
echo "вызов imap_renamemailbox для нового ящика завершился ошибкой: " . imap_last_error() . "<br />\n";
}
} else {
echo "вызов imap_status для нового ящика завершился ошибкой: " . imap_last_error() . "<br />\n";
}
if (@imap_deletemailbox($mbox, "{imap.example.org}INBOX.$newname")) {
echo "новый почтовый ящик удалён для восстановления первоначального состояния<br />\n";
} else {
echo "вызов imap_deletemailbox на новом почтовом ящике завершился ошибкой: " . implode("<br />\n", imap_errors()) . "<br />\n";
}
} else {
echo "невозможно создать новый почтовый ящик: " . implode("<br />\n", imap_errors()) . "<br />\n";
}
imap_close($mbox);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>imap_renamemailbox</function></member>
<member><function>imap_deletemailbox</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
-->