I need to provide an email form on my website that'll email members. I want to be able to set custom mail headers before the email is sent (I'm using Mandrill, so custom headers allow me additional features). I don't see anything in the docs about custom mail headers: https://ellislab.com/expressionengine/user-guide/development/usage/email.html
Is this possible to do in EE?
UPDATE 1:
I created an extension. And looking at this: https://ellislab.com/expressionengine/user-guide/development/extension_hooks/global/email/index.html -- it seems I should be able to set the headers by manipulating $data['headers']
. I have this in my extension:
function email_send(&$data)
{
$data['subject'] = 'Hello World';
$data['headers']['foo'] = 'bar';
}
When I receive the email, the subject is "Hello World". However, when I look at the headers, I do not see foo
=> bar
in it. I've checked with my host to see if there is anything that the hosting might be doing to strip custom headers. They claim no. So, the next question: is there anything in EE that might be preventing me from setting custom headers?
I'm currently configured to use PHP Mail, but I do want to use SMTP for this eventually.
UPDATE 2:
When I configure CPanel to use either Sendmail
or SMTP
, the subject does not get set to "Hello World". Instead, it says "Contact Form Email". Summary:
- Subject only gets set when in PHP Mail
- Email headers not set in PHP Mail, Sendmail, or SMTP