当前位置: 首页>>代码示例>>PHP>>正文


PHP UserMailer::sendInternal方法代码示例

本文整理汇总了PHP中UserMailer::sendInternal方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMailer::sendInternal方法的具体用法?PHP UserMailer::sendInternal怎么用?PHP UserMailer::sendInternal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserMailer的用法示例。


在下文中一共展示了UserMailer::sendInternal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 /**
  * This function will perform a direct (authenticated) login to
  * a SMTP Server to use for mail relaying if 'wgSMTP' specifies an
  * array of parameters. It requires PEAR:Mail to do that.
  * Otherwise it just uses the standard PHP 'mail' function.
  *
  * @param MailAddress|MailAddress[] $to Recipient's email (or an array of them)
  * @param MailAddress $from Sender's email
  * @param string $subject Email's subject.
  * @param string $body Email's text or Array of two strings to be the text and html bodies
  * @param array $options:
  * 		'replyTo' MailAddress
  * 		'contentType' string default 'text/plain; charset=UTF-8'
  * 		'headers' array Extra headers to set
  *
  * Previous versions of this function had $replyto as the 5th argument and $contentType
  * as the 6th. These are still supported for backwards compatability, but deprecated.
  *
  * @throws MWException
  * @throws Exception
  * @return Status
  */
 public static function send($to, $from, $subject, $body, $options = array())
 {
     global $wgAllowHTMLEmail;
     $contentType = 'text/plain; charset=UTF-8';
     if (!is_array($options)) {
         // Old calling style
         wfDeprecated(__METHOD__ . ' with $replyto as 5th parameter', '1.26');
         $options = array('replyTo' => $options);
         if (func_num_args() === 6) {
             $options['contentType'] = func_get_arg(5);
         }
     }
     if (!is_array($to)) {
         $to = array($to);
     }
     // mail body must have some content
     $minBodyLen = 10;
     // arbitrary but longer than Array or Object to detect casting error
     // body must either be a string or an array with text and body
     if (!(!is_array($body) && strlen($body) >= $minBodyLen) && !(is_array($body) && isset($body['text']) && isset($body['html']) && strlen($body['text']) >= $minBodyLen && strlen($body['html']) >= $minBodyLen)) {
         // if it is neither we have a problem
         return Status::newFatal('user-mail-no-body');
     }
     if (!$wgAllowHTMLEmail && is_array($body)) {
         // HTML not wanted.  Dump it.
         $body = $body['text'];
     }
     wfDebug(__METHOD__ . ': sending mail to ' . implode(', ', $to) . "\n");
     // Make sure we have at least one address
     $has_address = false;
     foreach ($to as $u) {
         if ($u->address) {
             $has_address = true;
             break;
         }
     }
     if (!$has_address) {
         return Status::newFatal('user-mail-no-addy');
     }
     // give a chance to UserMailerTransformContents subscribers who need to deal with each
     // target differently to split up the address list
     if (count($to) > 1) {
         $oldTo = $to;
         Hooks::run('UserMailerSplitTo', array(&$to));
         if ($oldTo != $to) {
             $splitTo = array_diff($oldTo, $to);
             $to = array_diff($oldTo, $splitTo);
             // ignore new addresses added in the hook
             // first send to non-split address list, then to split addresses one by one
             $status = Status::newGood();
             if ($to) {
                 $status->merge(UserMailer::sendInternal($to, $from, $subject, $body, $options));
             }
             foreach ($splitTo as $newTo) {
                 $status->merge(UserMailer::sendInternal(array($newTo), $from, $subject, $body, $options));
             }
             return $status;
         }
     }
     return UserMailer::sendInternal($to, $from, $subject, $body, $options);
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:83,代码来源:UserMailer.php


注:本文中的UserMailer::sendInternal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。