FEATURE REQUEST: email template headers

6 posts by 2 authors in: Forums > CMS Builder
Last Post: June 23, 2014   (RSS)

By kitsguru - June 13, 2014

It would be useful to add additional optional headers to the email templates such as CC, BCC and Reply-To

From the forums there appears to be some demand for this functionality.

I have set up my app to send all transactional email through mandrill which works extremely well. Currently when someone signs up via the membership plug in, an email is sent to the user with their password. I have also added a call to send a message to admin that a new user has been added. I would like to set the "reply to" header to be the user's email. Using the users email in the from address when using mandrill works but impacts sending domain validation.

Jeff Shields

By Dave - June 19, 2014

Hi Jeff, 

Where do you want to add reply-to?  To the default signup message or to your custom admin message that you added?

There's no functionality in the plugin for it but there is functionality in the internal sendMessage function in /lib/common.php as you can see in the function header in that file:

// Full Featured Example:
  $errors = sendMessage(array(
    'from'    => "from@example.com",
    'to'      => "to@example.com",
    'subject' => "Enter subject here, supports utf-8 content",
    'text'    => "Text message content",
    'html'    => "<b>HTML</b> message content",
    'headers' => array(
      "CC"          => "cc@example.com",
      "BCC"         => "bcc@example.com",
      "Reply-To"    => "rt@example.com",
      "Return-Path" => "rp@example.com",
    'attachments' => array(
      'simple.txt'  => 'A simple text file',
      'dynamic.csv' => $csvData,
      'archive.zip' => $binaryData,
      'image.jpg'   => file_get_contents($imagePath),
    //'disabled' => false, // set to true to disable sending of message
    //'logging' => false, // set to false to disable logging (if logging is already enabled) - used for background mailers

So you might be able to add it by adding a 'headers' => array('Reply-To' => $email), field.

Hope that helps!

Dave Edis - Senior Developer

By kitsguru - June 19, 2014

Hi Dave,

Yes I know I can add additional headers there which is what I did, but I was suggesting to add them  in the EMAIL TEMPLATES themselves.

Why code it when it could be stored in the database? Seems redundant to have the templates and then need to override/supplement them in custom code. For instance:

FROM: admin

TO: admin

Reply To: user

This is handy for signup forms with the email going to the admin but allows admin to do a reply to user. Especially handy when using Mandrill for mail handling as you don't want the from address to be the user's.

Jeff Shields

By Dave - June 19, 2014

Hi Jeff, 

Ok, the issue we don't want to add too many fields, or we end up with something that isn't any more simple than a programming language.  So most of what we do design wise is try to limit it to what's absolutely essential.

But as you say, with sending domain validation it can become an issue.  I'm wondering if it even makes sense being able to specify a different from: email for each template.

In any case, what fields do you want added?  Reply-to, CC, and BCC?  To the "Email Templates" section, correct?  I'll see what I can come up with for that.

Dave Edis - Senior Developer

By kitsguru - June 19, 2014

I understand your concern about added fields.

Since as a general rule emails will/should always be from admin, I would agree that FROM might be unnecessary. CC or BCC might of use to some, but I prefer using a different email to admin than a copy of the one to the user.

I find it practical to add a second call to send an mail using a different template to admin (which I discovered needs to be before the one to user) .

Use Case

REPLY TO does not impact the original email destination but could very well be different for each email for a reply.

FROM admin, TO user REPLY TO [sales|billing|support]

FROM admin TO admin REPLY TO user

Jeff Shields