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); } }