PHP.mk документација

imap_mail_compose

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.imap-mail-compose.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.imap-mail-compose.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
imap_mail_compose

Референца за `function.imap-mail-compose.php` со подобрена типографија и навигација.

function.imap-mail-compose.php

imap_mail_compose

(PHP 4, PHP 5, PHP 7, PHP 8)

imap_mail_composeCreate a MIME message based on given envelope and body sections

= NULL

imap_mail_compose(array $envelope, array $bodies): string|false

Креирај MIME порака врз основа на дадени делови за обвивка и тело envelope and bodies sections.

Параметри

envelope

Креирај MIME порака врз основа на даденото "remail", "return_path", "date", "from", "reply_to", "in_reply_to", "subject", "to", "cc", "bcc" and "message_id"Асоцијативен список на полиња за заглавие. Валидни клучеви се: string, кои ги поставуваат соодветните заглавија на пораката на даденото "custom_headers" . За поставување дополнителни заглавија, клучот ["User-Agent: My Mail Client"].

bodies

се поддржува, кој очекува список на тие заглавија, на пр. TYPEMULTIPARTИндексиран список на тела. Првото тело е главното тело на пораката; само ако има тип

, се обработуваат понатамошни тела; овие тела ги сочинуваат телата на деловите.
Можни индекси на низи за Тип = NULL
type int Структура на список на тело TYPETEXT (стандардно), TYPEMULTIPART, TYPEMESSAGE, TYPEAPPLICATION, TYPEAUDIO, TYPEIMAGE, TYPEMODEL or TYPEOTHER.
encoding int На Content-Transfer-EncodingMIME типот. Еден од ENC7BIT (стандардно), ENC8BIT, ENCBINARY, ENCBASE64, ENCQUOTEDPRINTABLE or ENCOTHER.
charset string . Еден од
type.parameters array Асоцијативен array of Content-Type Параметарот за карактер на MIME типот.
subtype string имиња на параметри и нивните вредности. 'jpeg' for TYPEIMAGE.
id string На Content-ID.
description string На Content-Description.
disposition.type string На Content-Disposition, на пр. 'attachment'.
disposition array Асоцијативен array of Content-Disposition MIME подтипот, на пр.
contents.data string имиња и вредности на параметри.
lines int Товарот.
bytes int Големината на товарот во редови.
md5 string Големината на товарот во бајти.

Вратени вредности

MD5 сума на товарот. string, или false при неуспех.

Примери

Пример #1 imap_mail_compose() example

<?php

$envelope
["from"]= "[email protected]";
$envelope["to"] = "[email protected]";
$envelope["cc"] = "[email protected]";

$part1["type"] = TYPEMULTIPART;
$part1["subtype"] = "mixed";

$filename = "/tmp/imap.c.gz";
$fp = fopen($filename, "r");
$contents = fread($fp, filesize($filename));
fclose($fp);

$part2["type"] = TYPEAPPLICATION;
$part2["encoding"] = ENCBINARY;
$part2["subtype"] = "octet-stream";
$part2["description"] = basename($filename);
$part2["contents.data"] = $contents;

$part3["type"] = TYPETEXT;
$part3["subtype"] = "plain";
$part3["description"] = "description3";
$part3["contents.data"] = "contents.data3\n\n\n\t";

$body[1] = $part1;
$body[2] = $part2;
$body[3] = $part3;

echo
nl2br(imap_mail_compose($envelope, $body));

?>

Белешки од корисници 5 белешки

Гвидо
пред 17 години
For some email clients its necessary first to start with the body text and end with the attachment(s). Otherwise all the parts end up in attachments, also the body text (took a while to find this).

So example #1 (above) should be switched over, like:

$body[1] = $part1;
$body[2] = $part3;
$body[3] = $part2;
jvandeweghe на kipsu точка com
пред 8 години
The custom_headers envelope documentation is misleading. Its not actually an "associative array", its a regular array of headers.

This is wrong:

<?php
$envelope = [
    //...
    "custom_headers" => [
        "X-SES-CONFIGURATION-SET" => "example",
        "X-SES-MESSAGE-TAGS" => "emailType=example"
    ]
];
?>

This is right:

<?php
$envelope = [
    //...
    "custom_headers" => [
        "X-SES-CONFIGURATION-SET: example",
        "X-SES-MESSAGE-TAGS: emailType=example"
    ]
];
?>
prices на dflytech точка com
figroc at gmail dot com
The documentation above does not mention that you can use the index ["charset"] to set the character set of the messsage part.

Example:

$part1["type"]= "TEXT";
$part1["subtype"]="PLAIN";
$part1["charset"] = "koi8-r";

to send a message in Russian-koi8.

Scott  =)
Заборавените
пред 23 години
If you wish to send the output of this function, simply use it for the headers argument of imap_mail() or mail().  Keep in mind that those functions set the To: and Subject: headers, so including them in the envelope will create double entries.
thomas точка hebinck на digionline точка de
пред 22 години
It is a good idea to set the date header:
$envelope['date']=date('r');
Навигација

Прелистувај сродни теми и функции.

На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.