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


PHP UserMailer::quotedPrintable方法代碼示例

本文整理匯總了PHP中UserMailer::quotedPrintable方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserMailer::quotedPrintable方法的具體用法?PHP UserMailer::quotedPrintable怎麽用?PHP UserMailer::quotedPrintable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserMailer的用法示例。


在下文中一共展示了UserMailer::quotedPrintable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: toString

 /**
  * Return formatted and quoted address to insert into SMTP headers
  * @return string
  */
 function toString()
 {
     # PHP's mail() implementation under Windows is somewhat shite, and
     # can't handle "Joe Bloggs <joe@bloggs.com>" format email addresses,
     # so don't bother generating them
     if ($this->address) {
         if ($this->name != '' && !wfIsWindows()) {
             global $wgEnotifUseRealName;
             $name = $wgEnotifUseRealName && $this->realName ? $this->realName : $this->name;
             $quoted = UserMailer::quotedPrintable($name);
             if (strpos($quoted, '.') !== false || strpos($quoted, ',') !== false) {
                 $quoted = '"' . $quoted . '"';
             }
             return "{$quoted} <{$this->address}>";
         } else {
             return $this->address;
         }
     }
 }
開發者ID:natalieschauser,項目名稱:csp_media_wiki,代碼行數:23,代碼來源:UserMailer.php

示例2: send

 public static function send($headers, $to, $from, $subject, $body, $priority = 0, $attachments = null)
 {
     global $wgEnotifMaxRecips, $wgSMTP;
     wfProfileIn(__METHOD__);
     require_once 'Mail2.php';
     require_once 'Mail2/mime.php';
     $logContext = array_merge($headers, ['issue' => 'SOC-910', 'method' => __METHOD__, 'to' => $to, 'subject' => $subject]);
     WikiaLogger::instance()->info('Queuing email for SendGrid', $logContext);
     wfSuppressWarnings();
     $headers['Subject'] = UserMailer::quotedPrintable($subject);
     // Add a header for the server-name (helps us route where SendGrid will send bounces).
     if (!empty($_SERVER) && isset($_SERVER['SERVER_NAME'])) {
         $headers["X-ServerName"] = $_SERVER['SERVER_NAME'];
     }
     try {
         $mail_object =& Mail2::factory(WikiaSendgridMailer::$factory, $wgSMTP);
     } catch (Exception $e) {
         $logContext['errorMessage'] = $e->getMessage();
         WikiaLogger::instance()->info('Failed to create mail object', $logContext);
         wfDebug("PEAR::Mail factory failed: " . $e->getMessage() . "\n");
         wfRestoreWarnings();
         wfProfileOut(__METHOD__);
         return $e->getMessage();
     }
     $email_body_txt = $email_body_html = "";
     if (is_array($body)) {
         if (isset($body['text'])) {
             $email_body_txt = $body['text'];
         }
         if (isset($body['html'])) {
             $email_body_html = $body['html'];
         }
     } else {
         $email_body_txt = $body;
     }
     $mime = new Mail_mime();
     $mime->setTXTBody($email_body_txt);
     $params = array('head_charset' => 'UTF-8', 'html_charset' => 'UTF-8', 'text_charset' => 'UTF-8', 'text_encoding' => 'quoted-printable', 'html_encoding' => 'quoted-printable');
     # send email with attachements
     if (!empty($attachments)) {
         if (!is_array($attachments)) {
             $attachments = array($attachments);
         }
         foreach ($attachments as $file) {
             if (!is_array($file)) {
                 $magic = MimeMagic::singleton();
                 $mimeType = $magic->guessMimeType($file);
                 $ext_file = end(explode('.', $file));
                 $file = array('file' => $file, 'ext' => $ext_file, 'mime' => $mimeType);
             }
             $filename = $file['file'];
             $ext_filename = $file['ext'];
             if (!file_exists($filename)) {
                 continue;
             }
             $name = $filename;
             #basename( $filename );
             if ($ext_filename) {
                 $name = $filename . "." . $ext_filename;
             }
             $mime->addAttachment($filename, $file['mime'], $name);
         }
     }
     # Old version (1.16 MW with Wikia changes) of sendHTML method
     if ($email_body_html) {
         $mime->setHTMLBody($email_body_html);
         //do not ever try to call these lines in reverse order
     }
     $body = $mime->get($params);
     $headers = $mime->headers($headers);
     wfDebug("Sending mail via WikiaSendgridMailer::send\n");
     $chunks = array_chunk((array) $to, $wgEnotifMaxRecips);
     foreach ($chunks as $chunk) {
         $headers['To'] = $chunk;
         $status = self::sendWithPear($mail_object, $chunk, $headers, $body);
         if (!$status->isOK()) {
             $logContext['errorMessage'] = $status->getMessage();
             WikiaLogger::instance()->info('Failed to create mail object', $logContext);
             wfRestoreWarnings();
             wfProfileOut(__METHOD__);
             return $status->getMessage();
         }
     }
     wfProfileOut(__METHOD__);
     # return false to return Status::newGood() in UserMailer::send method
     return false;
 }
開發者ID:yusufchang,項目名稱:app,代碼行數:87,代碼來源:WikiaMailer.php

示例3: testQuotedPrintable

 /**
  * @covers UserMailer::quotedPrintable
  */
 public function testQuotedPrintable()
 {
     $this->assertEquals("=?UTF-8?Q?=C4=88u=20legebla=3F?=", UserMailer::quotedPrintable("Ĉu legebla?", "UTF-8"));
 }
開發者ID:MediaWiki-stable,項目名稱:1.26.1,代碼行數:7,代碼來源:UserMailerTest.php


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