function send_template_email($to, $subject, $template, $skin, $output = array(), $message_body = '') { $myreturn = true; if (empty($message_body)) { if (isset($GLOBALS['tpl'])) { global $tpl; $old_root = $tpl->get_root(); $tpl->set_root(_BASEPATH_ . '/skins_site/' . $skin . '/'); } else { $tpl = new phemplate(_BASEPATH_ . '/skins_site/' . $skin . '/', 'remove_nonjs'); } $tpl->set_file('temp', 'emails/' . $template); if (!empty($output)) { $tpl->set_var('output', $output); } global $tplvars; $tpl->set_var('tplvars', $tplvars); $message_body = $tpl->process('temp', 'temp', TPL_LOOP | TPL_OPTLOOP | TPL_OPTIONAL | TPL_FINISH); $tpl->drop_var('temp'); $tpl->drop_var('output'); } $config = get_site_option(array('mail_from', 'mail_crlf'), 'core'); require_once _BASEPATH_ . '/includes/classes/phpmailer.class.php'; $mail = new PHPMailer(); $mail->IsHTML(true); $mail->From = $config['mail_from']; $mail->Sender = $config['mail_from']; $mail->FromName = _SITENAME_; if ($config['mail_crlf']) { $mail->LE = "\r\n"; } else { $mail->LE = "\n"; } $mail->IsMail(); $mail->AddAddress($to); $mail->Subject = $subject; $mail->Body = $message_body; if (!$mail->Send()) { $myreturn = false; $GLOBALS['topass']['message']['type'] = MESSAGE_ERROR; $GLOBALS['topass']['message']['text'] = $mail->ErrorInfo; require_once _BASEPATH_ . '/includes/classes/log_error.class.php'; new log_error(array('module_name' => 'send_template_email', 'text' => 'sending mail to ' . $to . ' failed:' . $message_body)); } if (isset($old_root)) { $tpl->set_root($old_root); } return $myreturn; }