There is a standard TXT e-mail. It would be great with a standard HTML e-mail also. E.g. drupal.org/project/mandrill sends in html as a standard. Doing that makes i really har do read the TXT-email as everything is on one line.

Comments

quicksketch’s picture

You can install http://drupal.org/project/mimemail to send HTML-based e-mail with Webform. I'm not sure if it is compatible with Mandrill at the same time or not.

quicksketch’s picture

Title: Supply a standard HTML version of the e-mail » Support Mandrill module HTML e-mails

To clarify, we only have a single check in Webform that identifies if an HTML-based e-mail solution is installed, then everything else checks it. In theory we could expand the function, or (as suggested in the current code's TODO), provide a hook for other modules to indicate to Webform that they support HTML. See http://api.drupalize.me/webform_email_html_capable

lsolesen’s picture

Or webform could support the mailsystem module which lets the users decide which class to use for sending e-mails?

quicksketch’s picture

Webform already supports Mailsystem (since Mailsystem is usable with ALL mails in all of Drupal). The thing that's not clear with Mailsystem is which mail classes provide HTML abilities. So again, this comes back to webform_email_html_capable(), and adding either a hook there or an explicit check for Mandrill.

nightlife2008’s picture

In the meanwhile I quickfixed my webform.module to support HTMLMail module as follows:

/**
 * Check if any available HTML mail handlers are available for Webform to use.
 */
function webform_email_html_capable() {
  // TODO: Right now we only support MIME Mail. Support others if available
  // through a hook?
  if (module_exists('mimemail')) {
    $mail_systems = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
    $enable = !isset($mail_systems['webform']) || $mail_systems['webform'] == 'MimeMailSystem';

    // We assume that if a solution exists even if it's not specified we should
    // use it. Webform will specify if e-mails sent with the system are plain-
    // text or not when sending each e-mail.
    if ($enable) {
      $GLOBALS['conf']['mail_system']['webform'] = 'MimeMailSystem';
      return TRUE;
    }
  } 
  elseif (module_exists('htmlmail')) {
    $mail_systems = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
    $enable = !isset($mail_systems['webform']) || $mail_systems['webform'] == 'HTMLMailSystem';
  
    // We assume that if a solution exists even if it's not specified we should
    // use it. Webform will specify if e-mails sent with the system are plain-
    // text or not when sending each e-mail.
    if ($enable) {
      $GLOBALS['conf']['mail_system']['webform'] = 'HTMLMailSystem';
      return TRUE;
    }
  }
  else {
    return FALSE;
  }
}
quicksketch’s picture

Thanks @nightlife2008. This actually looks pretty close to an accpetable approach. I would suggest just moving the if ($enable) { block outside the module checks so you don't have the same 7 lines of code in both places.

nightlife2008’s picture

Jup, should perhaps first determine the mailsystem class, and set it once to the webform mailsystem.

Then that variable could be hooked for other modules?

amberau79’s picture

Isn't there any way to bump this? There's still no hook when this problem was reported in July 2012? I'd really rather not hack the module to support Mandrill emails, which is surely a pretty common requirement?

quicksketch’s picture

@amberau79: Yes, you can provide a patch that incorporates the feedback in #6.

quicksketch’s picture

Status: Active » Closed (fixed)

So it looks like this issue actually has nothing to do with supporting "Mandrill" so much as providing support for HTMLMail (as the suggested changes in #5 show). You can use MIMEMail today with Mandrill module to send HTML e-mails through Mandrill. Support for HTMLMail already has a separate issue at #1267142: webform_email_html_capable should also check for existence of htmlmail module.

So basically, you can use whatever module you want to *send* the e-mails, including SMTP module or Mandrill. Webform uses MIME Mail module to *format* the e-mail before it is sent. Likewise HTML Mail provides this functionality too, but it's not yet supported. This issue therefor can be merged with #1267142: webform_email_html_capable should also check for existence of htmlmail module, since that what we're really talking about here.