IMAP, POP3 및 NNTP imap_mail_compose

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

imap_mail_compose — 주어진 envelope 및 본문 섹션을 기반으로 MIME 메시지 만들기


설명

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

주어진 envelopebodies 섹션을 기반으로 MIME 메시지를 만듭니다.


매개변수

envelope
헤더 필드의 연관 배열입니다. 유효한 키는 "remail", "return_path", "date", "from", "reply_to", "in_reply_to", "subject", "to", "cc", "bcc" 및 "message_id"입니다. 주어진 문자열에 대한 각각의 메시지 헤더. 추가 헤더를 설정하기 위해 "custom_headers" 키가 지원되며 이러한 헤더의 배열이 필요합니다. ["사용자 에이전트: 내 메일 클라이언트"].
bodies
인덱싱된 바디 배열입니다. 첫 번째 본문은 메시지의 본문입니다. 유형이 TYPEMULTIPART인 경우에만 추가 본문이 처리됩니다. 이러한 본체는 부품의 본체를 구성합니다.

Body Array Structure

Key Type 설명
type int The MIME type. One of TYPETEXT (default), TYPEMULTIPART, TYPEMESSAGE, TYPEAPPLICATION, TYPEAUDIO, TYPEIMAGE, TYPEMODEL or TYPEOTHER.
encoding int The Content-Transfer-Encoding. One of ENC7BIT (default), ENC8BIT, ENCBINARY, ENCBASE64, ENCQUOTEDPRINTABLE or ENCOTHER.
charset string The charset parameter of the MIME type.
type.parameters array An associative array of Content-Type parameter names and their values.
subtype string The MIME subtype, e.g. 'jpeg' for TYPEIMAGE.
id string The Content-ID.
description string The Content-Description.
disposition.type string The Content-Disposition, e.g. 'attachment'.
disposition array An associative array of Content-Disposition parameter names and values.
contents.data string The payload.
lines int The size of the payload in lines.
bytes int The size of the payload in bytes.
md5 string The MD5 checksum of the payload.

반환 값

IME 메시지를 문자열로 반환하거나 실패 시 false를 반환합니다.


Examples

예제 #1 imap_mail_compose() 예제

                  
<?php

$envelope["from"]= "joe@example.com";
$envelope["to"]  = "foo@example.com";
$envelope["cc"]  = "bar@example.com";

$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));

?>