define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors // 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]);
* Fifth Floor, Boston, MA 02110-1301, USA * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Purpose: - send a mail message using 'SendMail' Unix program */ // manage errors error_reporting(E_ALL); // php errors define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors // path to 'MAIL.php' file from XPM4 package require_once '../MAIL.php'; // initialize MAIL class $m = new MAIL(); // set from address $m->From('*****@*****.**'); // optional, set return-path // $m->Path('*****@*****.**'); // add to address $m->AddTo('*****@*****.**'); // set subject $m->Subject('Hello World!'); // set text message $m->Text('Text message.'); // optional, you can change the execution program for 'sendmail', by default is '/usr/sbin/sendmail' // $m->SendMail = '/path-to/your-mail-program'; // send mail using 'SendMail' Unix program, or type 'qmail' to select 'QMail' program echo $m->Send('sendmail') ? 'Mail sent !' : 'Error !'; // optional, print History for debugging print_r($m->History);
function send_email($sendto, $subject, $content, $fromemail = "", $fromname = "", $html = false) { if (in_array($fromemail, array('', 'root@localhost')) || !is_email($fromemail) || empty($fromname)) { return; } require_once library_path() . 'xpertmailer' . DIRECTORY_SEPARATOR . 'MAIL.php'; $mail = new MAIL(); $mail->From($fromemail, $fromname); $mail->AddTo($sendto); $mail->Subject($subject); if ($html) { $mail->HTML($html); } $mail->Text($content); $c = $mail->Connect(environment('email_server'), environment('email_port'), environment('email_user'), environment('email_pass')); $send = $mail->Send($c); $mail->Disconnect(); }