function mimemail_rfc_headers in Mime Mail 5
Same name and namespace in other branches
- 6 mimemail.inc \mimemail_rfc_headers()
- 7 mimemail.inc \mimemail_rfc_headers()
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
2 calls to mimemail_rfc_headers()
- mimemail_mailengine in ./
mimemail.module - The default mailengine.
- mimemail_multipart_body in ./
mimemail.inc
File
- ./
mimemail.inc, line 19
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);
}