function mimemail_headers in Mime Mail 5
Same name and namespace in other branches
- 6 mimemail.inc \mimemail_headers()
- 7 mimemail.inc \mimemail_headers()
Gives useful defaults for standard email headers.
Parameters
$headers An array of headers:
Return value
header string.
1 call to mimemail_headers()
- mimemail_prepare in ./
mimemail.module - Sends a mime-encoded e-mail.
File
- ./
mimemail.inc, line 48
Code
function mimemail_headers($headers, $from = '') {
// Note: This may not work. The MTA may rewrite the Return-Path, and Errors-To is deprecated.
if (!$from) {
$from = variable_get('site_mail', ini_get('sendmail_from'));
}
preg_match('/[a-z0-9\\-\\.]+@{1}[a-z0-9\\-\\.]+/i', $from, $matches);
$from_email = $matches[0];
// allow a mail to overwrite standard headers.
$headers = array_merge(array(
'Return-Path' => "<{$from_email}>",
'Errors-To' => $from,
'From' => $from,
'Content-Type' => 'text/plain; charset=utf-8; format=flowed',
), $headers);
// Run all headers through mime_header_encode() to convert non-ascii
// characters to an rfc compliant string, similar to drupal_mail().
foreach ($headers as $key => $value) {
$headers[$key] = mime_header_encode($value);
}
return $headers;
}