function send_email($goingto, $toname, $sbj, $messg) { global $Config; define('DISPLAY_XPM4_ERRORS', true); // display XPM4 errors $core_em = $Config->get('site_email'); // If email type "0" (SMTP) if ($Config->get('email_type') == 0) { require_once 'core/mail/SMTP.php'; // path to 'SMTP.php' file from XPM4 package $f = '' . $core_em . ''; // from mail address $t = '' . $goingto . ''; // to mail address // standard mail message RFC2822 $m = 'From: ' . $f . "\r\n" . 'To: ' . $t . "\r\n" . 'Subject: ' . $sbj . "\r\n" . 'Content-Type: text/plain' . "\r\n\r\n" . '' . $messg . ''; $h = explode('@', $t); // get client hostname $c = SMTP::MXconnect($h[1]); // connect to SMTP server (direct) from MX hosts list $s = SMTP::Send($c, array($t), $m, $f); // send mail // print result if ($s) { output_message('success', 'Mail Sent!'); } else { output_message('error', print_r($_RESULT)); } SMTP::Disconnect($c); // disconnect } elseif ($Config->get('email_type') == 1) { require_once 'core/mail/MIME.php'; // path to 'MIME.php' file from XPM4 package // compose message in MIME format $mess = MIME::compose($messg); // send mail $send = mail($goingto, $sbj, $mess['content'], 'From: ' . $core_em . '' . "\n" . $mess['header']); // print result echo $send ? output_message('success', 'Mail Sent!') : output_message('error', 'Error!'); } elseif ($Config->get('email_type') == 2) { require_once 'core/mail/MAIL.php'; // path to 'MAIL.php' file from XPM4 package $m = new MAIL(); // initialize MAIL class $m->From($core_em); // set from address $m->AddTo($goingto); // add to address $m->Subject($sbj); // set subject $m->Html($messg); // set html message // connect to MTA server 'smtp.hostname.net' port '25' with authentication: 'username'/'password' if ($Config->get('email_use_secure') == 1) { $c = $m->Connect($Config->get('email_smtp_host'), $Config->get('email_smtp_port'), $Config->get('email_smtp_user'), $Config->get('email_smtp_pass'), $Config->get('email_smtp_secure')) or die(print_r($m->Result)); } else { $c = $m->Connect($Config->get('email_smtp_host'), $Config->get('email_smtp_port'), $Config->get('email_smtp_user'), $Config->get('email_smtp_pass')) or die(print_r($m->Result)); } // send mail relay using the '$c' resource connection echo $m->Send($c) ? output_message('success', 'Mail Sent!') : output_message('error', 'Error! Please check your config and make sure you inserted your MTA info correctly.'); $m->Disconnect(); // disconnect from server // print_r($m->History); // optional, for debugging } }
*/ // 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'; // 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>';
* 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(); }