本文整理汇总了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;
}
示例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;
}
示例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;
}