Exemplo n.º 1
0
// manage errors
error_reporting(E_ALL);
// php errors
define('DISPLAY_XPM4_ERRORS', true);
// display XPM4 errors
// path to 'MIME.php' file from XPM4 package
require_once '../MIME.php';
// COMPOSE message ----------------------------------
$id = MIME::unique();
// set text/plain version of message
$text = MIME::message('Text version of message.', 'text/plain');
// set text/html version of message with an embed image
$html = MIME::message('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:' . $id . '">', 'text/html');
// add attachment with name 'file.txt'
$at[] = MIME::message('source file', 'text/plain', 'file.txt', 'ISO-8859-1', 'base64', 'attachment');
$file = 'xpertmailer.gif';
// add inline attachment '$file' with name 'XPM.gif' and ID '$id'
$at[] = MIME::message(file_get_contents($file), FUNC::mime_type($file), 'XPM.gif', null, 'base64', 'inline', $id);
// compose mail message in MIME format
$mess = MIME::compose($text, $html, $at);
// standard mail message RFC2822
$mail = 'From: my@addr.com' . "\r\n" . 'To: me@addr.net' . "\r\n" . 'Subject: test' . "\r\n" . $mess['header'] . "\r\n\r\n" . $mess['content'];
// die($mail); // << uncomment this line to see the mail source
// SPLIT message ------------------------------------
$split = MIME::split_mail($mail, $headers, $body);
// print results
echo '<br /><pre>MAIL HEADERS ####################################' . "\n";
print_r($headers);
echo '<br />MAIL BODY PARTS #################################' . "\n";
print_r($body);
echo '</pre>';