本文整理汇总了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;
}
}
}
示例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;
}
示例3: testQuotedPrintable
/**
* @covers UserMailer::quotedPrintable
*/
public function testQuotedPrintable()
{
$this->assertEquals("=?UTF-8?Q?=C4=88u=20legebla=3F?=", UserMailer::quotedPrintable("Ĉu legebla?", "UTF-8"));
}