當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserMailer::mErrorString方法代碼示例

本文整理匯總了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);
 }
開發者ID:eliagbayani,項目名稱:LiteratureEditor,代碼行數:10,代碼來源:UserMailer.php

示例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();
         }
     }
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:101,代碼來源:UserMailer.php


注:本文中的UserMailer::mErrorString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。