Is there any way to theme the emails being sent? Send as HTML emails with a banner/logo.

The plain text of the Subscription email sent is rather boring to my eyes.

I'd also like to add in ads I have on my site in the emails sent out...is that out of the realm of possabilities?

Comments

chiddicks’s picture

Since the email templates are editing using the mail_edit tool, you should be inquiring there. Right now you can't send HTML emails, but that feature has certainly been asked for by others. Perhaps in the near future it could be added.

mdowsett’s picture

Title: theming the emails » send HTML emails

thx. I suppose the issue is for Subscriptions to allow HTML emails...so I'll leave the issue here.

I have the HTML to text module installed and active now which strips out the HTML code so the Subscription emails are at least readable (plain text) but I'd rather it (Subscriptions) be able theme the email with my themes css styles.

It sounds like that is the way it should be in the first place - or at least have option to send either plain text or HTML emails. I want to embed images, etc in the emails sent out as well as clickable hyperlinks.

salvis’s picture

I think that trying to send out HTML emails would be
a) difficult to implement correctly and satisfactorily
b) a constant source of feature requests for additional tweaking possibilities
c) a constant source of support requests of the type "why don't my emails look like I want them to?"

Just look at the discussions we're already having with the text-only format...

However, due to the modular nature of Subscriptions, it should be possible to implement subscriptions_html_mail.module as an alternative to subscriptions_mail.module, and if someone wants to develop (and support this!) as a separate add-on project, then I'll certainly help.

RachelNY’s picture

Salvis,

I change my setup to HTML email with a very simple edit:

/**
 * Implementation of hook_mail().
 */
function subscriptions_mail_mail($key, &$message, $params) {
  global $base_url;
  
  $url = parse_url($base_url);
  $list_id = variable_get('site_name', '') .' '. t('Subscriptions') .' <subscriptions.'. $url['host'] .'>'; 
  
  $message['subject'] = $params['context']['subject'];
  $message['body'] = $params['context']['message'];
  $message['headers']['List-Id'] = $list_id;
// Edit START Change Subscriptions Module email to html
  $message['headers']['Content-Transfer-Encoding'] = '8bit';
  $message['headers']['Content-Type'] = "text/html; charset='utf-8';";
// Edit END Change Subscriptions Module email to html
}

Then I edited the templates using "Mail templates".

This whole process was very simple and does not require any additional tweaking or support as all the email customization can be done in the template file directly.

I remain, however, extremely uneasy with what I did as this is the only module I have edited directly outside of my 'theme' folder.

First, is there a way to accomplish this through a file in my 'theme' folder rather than a direct edit of the 'subscriptions_mail.module' file?

Second, as a compromise, will you add a "send email in HTML" checkbox which activates the above code with the understanding that you will not support anything outside of the base functionality and all HTML customization must be done by the admin using "Mail templates"? I think this is a reasonable compromise.

If you can't/won't add this, can you help me implement it in a way that will not mess up my upgrade path as I have done with the direct module edit?

Thanks,
Rachel

salvis’s picture

Thank you for approaching this in a pro-active way, but this is too simple. There are several issues with your solution:

  1. The text would need to be piped through check_plain() to ensure that your not opening up the door to HTML exploits.
  2. Actually, we're going out of our way to convert the body text to plain text, rendering any HTML in plain text as well as possible. Taking that and displaying it as HTML means that we'd remove line breaks, for example.
  3. HTML mail should include an alternative text part. Not including that is spammy and may make the message unreadable to some clients.
  4. Embedded URLs won't be clickable in most clients.

I don't think you can do this in the themes folder, but if you have D6, you can create a simple module and make your desired changes in http://api.drupal.org/api/function/hook_mail/6.

RachelNY’s picture

Hi salvis,

I've only been using Drupal for about 3 weeks and need the HTML mail to be able to port this particular site over ... I am not quite up to working on a module yet ... I'll leave my "brute force" solution in place until I have a chance to get a better feel for how the core systems function -- for now the email notifications look and function exactly as they need to ...

I'm looking forward to having a greater familiarity with the system and being able to jump in to help out ... For now, this sure beats custom coding everything ...

Thanks again, the Subscriptions module is definitely doing the trick here ...

Rachel

salvis’s picture

Ok, great — good luck, and see you again...

EDIT: Please keep in mind that you'll have problems as soon as someone types angle brackets (<), ampersands, or such stuff...

Hans

lindsay’s picture

Title: send HTML emails » send HTML emails - Mime Mail

Could you set up Subscriptions to support Mime Mail? http://drupal.org/project/mimemail

It just seems that the ability to send html email is already nicely wrapped in a separate module that you (salvis) don't have to maintain. And it's purpose is to support other modules.

lindsay’s picture

Status: Active » Closed (fixed)

Never mind, I see someone else suggested this already here: http://drupal.org/node/568032

salvis’s picture

I'm just not sure how to package that (and keep plain-text the default).

If you have any ideas then please add to the other issue.