function Messaging_HTML_MailSystem::mimemail_rfc_headers in Messaging 7
Attempts to RFC822-compliant headers for the mail message or its MIME parts TODO could use some enhancement and stress testing
Parameters
$headers An array of headers:
Return value
header string
1 call to Messaging_HTML_MailSystem::mimemail_rfc_headers()
- Messaging_HTML_MailSystem::mimemail_multipart_body in messaging_htmlmail/
messaging_htmlmail.inc
File
- messaging_htmlmail/
messaging_htmlmail.inc, line 391 - Drupal Messaging Framework - Send_Method class file
Class
- Messaging_HTML_MailSystem
- Sendgrid mail system
Code
function mimemail_rfc_headers($headers) {
$header = '';
$crlf = variable_get('mimemail_crlf', "\n");
foreach ($headers as $key => $value) {
$key = trim($key);
// collapse spaces and get rid of newline characters
$value = preg_replace('/(\\s+|\\n|\\r|^\\s|\\s$)/', ' ', $value);
//fold headers if they're too long
if (strlen($value) > 60) {
//if there's a semicolon, use that to separate
if (count($array = preg_split('/;\\s*/', $value)) > 1) {
$value = trim(join(";{$crlf} ", $array));
}
else {
$value = wordwrap($value, 50, "{$crlf} ", FALSE);
}
}
$header .= "{$key}: {$value}{$crlf}";
}
return trim($header);
}