imap_mail_compose
imap_mail_compose
Create a MIME message based on given envelope and body sections
**imap_mail_compose** array $envelope array $bodies
Create a MIME message based on the given
and sections.
envelope``bodies
envelope
An associative array of header fields. Valid keys are: ,
, , , , , ,
, , and , which set the respective message headers to the given string.
To set additional headers, the key is supported, which expects
an array of those headers, e.g. .
"remail"``"return_path"``"date"``"from"``"reply_to"``"in_reply_to"``"subject"``"to"``"cc"``"bcc"``"message_id"``"custom_headers"``["User-Agent: My Mail Client"]
bodies
An indexed array of bodies. The first body is the main body of the message;
only if it has a type of , further bodies
are processed; these bodies constitute the bodies of the parts.
TYPEMULTIPART
Returns the MIME message as string, return.falseforfailure.
Voorbeeld: example
<?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));
?>