The following is my code for sending mail with PHP (within the context of a custom Email class). If I change the first parameter of Mail::factory() to 'mail', Exim will add the Message-ID and Date headers, but as 'smtp' it does not. I don't want to use the 'mail' setting because it causes X-PHP headers to get added which cannot be disabled without forking the cpanel module from github which is a little out of the scope of what I'm trying to accomplish here. Any ideas as to why the 'smtp' option causes Exim to not add the missing headers? I can generate my own Message-ID and Date headers in PHP, but the Message-ID won't match Exim's internal Message-ID for the email and I'm worried that will cause consistency issues within Exim's general mail management.
PHP:
// Send locally
require_once('Mail.php');
require_once('Mail/mime.php');
$headers = array(
'From' => $this->fromName . ' <' . $this->fromEmail . '>',
'To' => implode(", ", $this->recipients),
'Subject' => $this->title
);
$mime = new Mail_mime("\n");
if( $this->useHtml || $this->useStandardTemplate ) {
$mime->setHTMLBody($message);
} else {
$mime->setTXTBody($message);
}
$body = $mime->get(array(
'text_encoding' => '7bit',
'text_charset' => 'UTF-8',
'html_charset' => 'UTF-8',
'head_charset' => 'UTF-8'
));
$headers = $mime->headers($headers);
$mail = &Mail::factory('smtp');
$mail->send( $this->recipients, $headers, $body );