当前位置: 首页>>代码示例>>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;未经允许,请勿转载。