function bcms_mail($address, $subject, $message) { global $_config; require_once SYSTEM_ROOT . './class/bcms.php'; $bcms = new Bcms(); $ret = $bcms->mail($_config['mail']['bcms']['queue'], '<!--HTML-->' . $message, array($address), array(Bcms::MAIL_SUBJECT => $subject)); if (false === $ret) { return false; } else { return true; } }
function wp_mail($to, $subject, $message, $headers = '', $attachments = array()) { // Headers if (empty($headers)) { $headers = array(); } else { if (!is_array($headers)) { // Explode the headers out, so this function can take both // string headers and an array of headers. $tempheaders = explode("\n", str_replace("\r\n", "\n", $headers)); } else { $tempheaders = $headers; } $headers = array(); // If it's actually got contents if (!empty($tempheaders)) { // Iterate through the raw headers foreach ((array) $tempheaders as $header) { // Explode them out list($name, $content) = explode(':', trim($header), 2); // Cleanup crew $name = trim($name); $content = trim($content); switch (strtolower($name)) { // Mainly for legacy -- process a From: header if it's there case 'from': if (strpos($content, '<') !== false) { // So... making my life hard again? $from_name = substr($content, 0, strpos($content, '<') - 1); $from_name = str_replace('"', '', $from_name); $from_name = trim($from_name); $from_email = substr($content, strpos($content, '<') + 1); $from_email = str_replace('>', '', $from_email); $from_email = trim($from_email); } else { $from_email = trim($content); } break; case 'content-type': if (strpos($content, ';') !== false) { list($type, $charset) = explode(';', $content); $content_type = trim($type); } else { $content_type = trim($content); } break; } } } } /* If we don't have an email from the input headers default to wordpress@$sitename * Some hosts will block outgoing mail from this address if it doesn't exist but * there's no easy alternative. Defaulting to admin_email might appear to be another * option but some hosts may refuse to relay mail from an unknown domain. See * http://trac.wordpress.org/ticket/5007. */ if (!isset($from_email)) { // Get the site domain and get rid of www. $sitename = strtolower($_SERVER['SERVER_NAME']); if (substr($sitename, 0, 4) == 'www.') { $sitename = substr($sitename, 4); } $from_email = 'no-reply@' . $sitename; } // Set Content-Type and charset // If we don't have a content-type from the input headers if (!isset($content_type)) { $content_type = 'text/plain'; } $content_type = apply_filters('wp_mail_content_type', $content_type); if ($content_type == 'text/html') { $header = "<!--HTML-->"; } // 重复引用,BaeException就是这里报的 // require_once ABSPATH . WPINC . '/Bcms.class.php'; $bcms = new Bcms(); // 利用bcms发信 $ret = $bcms->mail(BCMS_QUEUE, $header . $message, array($to), array(Bcms::FROM => $from_email, Bcms::MAIL_SUBJECT => $subject)); // 返回值 if (false === $ret) { return false; } else { return true; } }
function wp_mail($to, $subject, $message, $headers = '', $attachments = array()) { require_once ABSPATH . WPINC . '/Bcms.class.php'; $mail = get_option(XT_OPTION_MAIL); $sitename = strtolower($_SERVER['SERVER_NAME']); if (substr($sitename, 0, 4) == 'www.') { $sitename = substr($sitename, 4); } $from_email = 'no-reply@' . $sitename; if (!empty($mail) && !empty($mail['smtp_user']) && validate_email($mail['smtp_user'], false)) { $from_email = $mail['smtp_user']; } $bcms = new Bcms(); $ret = $bcms->mail(BCMS_QUEUE, $message, array($to), array(Bcms::FROM => $from_email, Bcms::MAIL_SUBJECT => $subject)); if (false === $ret) { return false; } else { return true; } }
public static function sendMail($queueName, $message, $address, $optional = array()) { /** 载入BCMS SDK */ require_once 'Bcms.class.php'; $settings = Helper::options()->plugin('CommentToMail'); $accessKey = $settings->aKey; $secretKey = $settings->sKey; $host = 'bcms.api.duapp.com'; if ($accessKey != '' && $secretKey != '') { $bcms = new Bcms($accessKey, $secretKey, $host); } else { $bcms = new Bcms(); } $opt = array(Bcms::FROM => $optional['from'], Bcms::MAIL_SUBJECT => $optional['subject']); $ret = $bcms->mail($queueName, $message, $address, $opt); if (false === $ret) { error_output('ERROR NUMBER: ' . $bcms->errno()); error_output('ERROR MESSAGE: ' . $bcms->errmsg()); } }
static function SendByBaeMail($msg, $destination = '', $extra = '') { $quename = C('BAE_BCMS_QUEUE'); if (empty($quename)) { trigger_error("please set BAE_BCMS_QUEUE(bcms queue name)"); } $bcms = new Bcms(); $destination = $destination ? $destination : C('LOG_DEST'); if (!is_array($destination)) { $destination = array($destination); } $extra = $extra ? $extra : C('LOG_EXTRA'); $option = array(); $p = '/(from)([ ]*):(.*)/i'; preg_match($p, $extra, $match); if (isset($match[3])) { $option = array(Bcms::FROM => trim($match[3])); } if (($ret = $bcms->mail($quename, $msg, json_encode($destination), $option)) === false) { trigger_error("Send Mail Failed,bcms errmessage is :[" . $bcms->errmsg() . "] error no is [" . $bcms->errno() . "] dest[{$destination}] and option is:" . var_export($option, true) . " msg info[{$msg}]", E_USER_WARNING); } }