本文整理汇总了PHP中UserMailer::mErrorString方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMailer::mErrorString方法的具体用法?PHP UserMailer::mErrorString怎么用?PHP UserMailer::mErrorString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserMailer
的用法示例。
在下文中一共展示了UserMailer::mErrorString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: errorHandler
/**
* Set the mail error message in self::$mErrorString
*
* @param int $code Error number
* @param string $string Error message
*/
static function errorHandler($code, $string)
{
self::$mErrorString = preg_replace('/^mail\\(\\)(\\s*\\[.*?\\])?: /', '', $string);
}
示例2: send
//.........这里部分代码省略.........
$headers['X-Priority'] = $priority;
}
$ret = wfRunHooks('AlternateUserMailer', [$headers, $to, $from, $subject, $body, $priority, $attachments]);
if ($ret === false) {
return Status::newGood();
} elseif ($ret !== true) {
return Status::newFatal('php-mail-error', $ret);
}
# MoLi: body can be an array with text and html message
# MW core uses only text version of email message, so $body as array should be used only with AlternateUserMailer hook
if (is_array($body) && isset($body['text'])) {
$body = $body['text'];
}
if (is_array(F::app()->wg->SMTP)) {
#
# PEAR MAILER
#
if (function_exists('stream_resolve_include_path')) {
$found = stream_resolve_include_path('Mail.php');
} else {
$found = Fallback::stream_resolve_include_path('Mail.php');
}
if (!$found) {
throw new MWException('PEAR mail package is not installed');
}
require_once 'Mail.php';
wfSuppressWarnings();
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory('smtp', F::app()->wg->SMTP);
if (PEAR::isError($mail_object)) {
wfDebug("PEAR::Mail factory failed: " . $mail_object->getMessage() . "\n");
wfRestoreWarnings();
return Status::newFatal('pear-mail-error', $mail_object->getMessage());
}
wfDebug("Sending mail via PEAR::Mail\n");
$headers['Subject'] = self::quotedPrintable($subject);
# When sending only to one recipient, shows it its email using To:
if (count($to) == 1) {
$headers['To'] = $to[0]->toString();
}
# Split jobs since SMTP servers tends to limit the maximum
# number of possible recipients.
$chunks = array_chunk($to, F::app()->wg->EnotifMaxRecips);
foreach ($chunks as $chunk) {
if (!wfRunHooks('ComposeMail', [$chunk, &$body, &$headers])) {
continue;
}
$status = self::sendWithPear($mail_object, $chunk, $headers, $body);
# FIXME : some chunks might be sent while others are not!
if (!$status->isOK()) {
wfRestoreWarnings();
return $status;
}
}
wfRestoreWarnings();
return Status::newGood();
} else {
#
# PHP mail()
#
# Line endings need to be different on Unix and Windows due to
# the bug described at http://trac.wordpress.org/ticket/2603
if (wfIsWindows()) {
$body = str_replace("\n", "\r\n", $body);
$endl = "\r\n";
} else {
$endl = "\n";
}
if (count($to) > 1) {
$headers['To'] = 'undisclosed-recipients:;';
}
$headers = self::arrayToHeaderString($headers, $endl);
wfDebug("Sending mail via internal mail() function\n");
self::$mErrorString = '';
$html_errors = ini_get('html_errors');
ini_set('html_errors', '0');
$safeMode = wfIniGetBool('safe_mode');
foreach ($to as $recip) {
if (!wfRunHooks('ComposeMail', array($recip, &$body, &$headers))) {
continue;
}
if ($safeMode) {
$sent = mail($recip, self::quotedPrintable($subject), $body, $headers);
} else {
$sent = mail($recip, self::quotedPrintable($subject), $body, $headers, F::app()->wg->AdditionalMailParams);
}
}
ini_set('html_errors', $html_errors);
if (self::$mErrorString) {
wfDebug("Error sending mail: " . self::$mErrorString . "\n");
return Status::newFatal('php-mail-error', self::$mErrorString);
} elseif (!$sent) {
// mail function only tells if there's an error
wfDebug("Unknown error sending mail\n");
return Status::newFatal('php-mail-error-unknown');
} else {
return Status::newGood();
}
}
}