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


PHP Mail_mime::_encodeHeaders方法代码示例

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


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

示例1: array

 function _encodeHeaders($input, $params = array())
 {
     require_once 'CRM/Utils/Rule.php';
     $emailValues = array();
     foreach ($input as $fieldName => $fieldValue) {
         $fieldNames = $emails = array();
         $hasValue = false;
         //multiple email w/ comma separate.
         $fieldValues = explode(',', $fieldValue);
         foreach ($fieldValues as $index => $value) {
             $value = trim($value);
             //might be case we have only email address.
             if (CRM_Utils_Rule::email($value)) {
                 $hasValue = true;
                 $emails[$index] = $value;
                 $fieldNames[$index] = 'FIXME_HACK_FOR_NO_NAME';
             } else {
                 $matches = array();
                 if (preg_match('/^(.*)<([^<]*)>$/', $value, $matches)) {
                     $hasValue = true;
                     $emails[$index] = $matches[2];
                     $fieldNames[$index] = trim($matches[1]);
                 }
             }
         }
         //get formatted values back in input
         if ($hasValue) {
             $input[$fieldName] = implode(',', $fieldNames);
             $emailValues[$fieldName] = implode(',', $emails);
         }
     }
     // encode the email-less headers
     $input = parent::_encodeHeaders($input, $params);
     // add emails back to headers, quoting these headers along the way
     foreach ($emailValues as $fieldName => $value) {
         $emails = explode(',', $value);
         $fieldNames = explode(',', $input[$fieldName]);
         foreach ($fieldNames as $index => &$name) {
             $name = str_replace('\\', '\\\\', $name);
             $name = str_replace('"', '\\"', $name);
             // CRM-5640 -if the name was actually doubly-quoted,
             // strip these(the next line will add them back);
             if (substr($name, 0, 2) == '\\"' && substr($name, -2) == '\\"') {
                 $name = substr($name, 2, -2);
             }
         }
         //combine fieldNames and emails.
         $mergeValues = array();
         foreach ($emails as $index => $email) {
             if ($fieldNames[$index] == 'FIXME_HACK_FOR_NO_NAME') {
                 $mergeValues[] = $email;
             } else {
                 $mergeValues[] = "\"{$fieldNames[$index]}\" <{$email}>";
             }
         }
         //finally get values in.
         $input[$fieldName] = implode(',', $mergeValues);
     }
     return $input;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:60,代码来源:FixedMailMIME.php

示例2: array

 function _encodeHeaders($input, $params = array())
 {
     // strip any emails from headers
     $emails = array();
     foreach ($input as $field => $value) {
         $matches = array();
         if (preg_match('/^(.*)<([^<]*)>$/', $value, $matches)) {
             $input[$field] = trim($matches[1]);
             $emails[$field] = $matches[2];
         }
     }
     // encode the email-less headers
     $input = parent::_encodeHeaders($input, $params);
     // add emails back to headers, quoting these headers along the way
     foreach ($emails as $field => $email) {
         $input[$field] = str_replace('\\', '\\\\', $input[$field]);
         $input[$field] = str_replace('"', '\\"', $input[$field]);
         // if the name was actually doubly-quoted, strip these (the next line will add them back); CRM-5640
         if (substr($input[$field], 0, 2) == '\\"' and substr($input[$field], -2) == '\\"') {
             $input[$field] = substr($input[$field], 2, -2);
         }
         $input[$field] = "\"{$input[$field]}\" <{$email}>";
     }
     return $input;
 }
开发者ID:bhirsch,项目名称:civicrm,代码行数:25,代码来源:FixedMailMIME.php

示例3: array

 function _encodeHeaders($input, $params = array())
 {
     // strip any emails from headers
     $emails = array();
     foreach ($input as $field => $value) {
         $matches = array();
         if (preg_match('/^(.*)<([^<]*)>$/', $value, $matches)) {
             $input[$field] = trim($matches[1]);
             $emails[$field] = $matches[2];
         }
     }
     // encode the email-less headers
     $input = parent::_encodeHeaders($input, $params);
     // add emails back to headers, quoting these headers along the way
     foreach ($emails as $field => $email) {
         $input[$field] = str_replace('\\', '\\\\', $input[$field]);
         $input[$field] = str_replace('"', '\\"', $input[$field]);
         $input[$field] = "\"{$input[$field]}\" <{$email}>";
     }
     return $input;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:21,代码来源:FixedMailMIME.php


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