예제 #1
0
// path to 'MAIL.php' file from XPM4 package
require_once '../MAIL.php';
// get ID value (random) for the embed image
$id = MIME::unique();
// initialize MAIL class
$m = new MAIL();
// set from address and name
$m->From('*****@*****.**', 'My Name');
// add to address and name
$m->AddTo('*****@*****.**', 'Client Name');
// set subject
$m->Subject('Hello World!');
// set text/plain version of message
$m->Text('Text version of message.');
// set text/html version of message
$m->Html('<b>HTML</b> version of <u>message</u>.<br><i>Powered by</i> <img src="cid:' . $id . '">');
// add attachment ('text/plain' file)
$m->Attach('source file', 'text/plain');
$f = 'xpertmailer.gif';
// add inline attachment '$f' file with ID '$id'
$m->Attach(file_get_contents($f), FUNC::mime_type($f), null, null, null, 'inline', $id);
// send mail
echo $m->Send('client') ? 'Mail sent !' : 'Error !';
// optional for debugging ----------------
echo '<br /><pre>';
// print History
print_r($m->History);
// calculate time
list($tm1, $ar1) = each($m->History[0]);
list($tm2, $ar2) = each($m->History[count($m->History) - 1]);
echo 'The process took: ' . (floatval($tm2) - floatval($tm1)) . ' seconds.</pre>';