From: Matthew Wire Date: Sat, 28 Apr 2018 14:00:31 +0000 (+0100) Subject: On some servers mail() fails when 'Cc' or 'Bcc' headers are defined but empty X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c69abeeed2701e9a43130ccb9e3f00c070ee71de;p=civicrm-core.git On some servers mail() fails when 'Cc' or 'Bcc' headers are defined but empty --- diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index bebd05169c..c56d9556e0 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -203,8 +203,15 @@ class CRM_Utils_Mail { CRM_Utils_Array::value('toEmail', $params), FALSE ); - $headers['Cc'] = CRM_Utils_Array::value('cc', $params); - $headers['Bcc'] = CRM_Utils_Array::value('bcc', $params); + + // On some servers mail() fails when 'Cc' or 'Bcc' headers are defined but empty. + foreach (['Cc', 'Bcc'] as $optionalHeader) { + $headers[$optionalHeader] = CRM_Utils_Array::value(strtolower($optionalHeader), $params); + if (empty($headers[$optionalHeader])) { + unset($headers[$optionalHeader]); + } + } + $headers['Subject'] = CRM_Utils_Array::value('subject', $params); $headers['Content-Type'] = $htmlMessage ? 'multipart/mixed; charset=utf-8' : 'text/plain; charset=utf-8'; $headers['Content-Disposition'] = 'inline';