Currently webform_email_html_capable() checks for the presence of the mimemail module and if you haven't already set a mail system for webmail it overrides it to use mimemail's.

This process is flawed because its lack of transparency makes it hard to diagnose problems with webform emails, especially when the rest of the site is using a non-default mail system (in my case Mandrill, and the question "why aren't my webform emails being sent with Mandril?!")

I should like to remove this line from the function:

  $GLOBALS['conf']['mail_system']['webform'] = 'MimeMailSystem';

And instead, in the .install file we need something in hook_requirements() (I guess it would go there?) that does something like this:

  if (module_exists('mimemail')) {
    $mail_systems = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
    if (!isset($mail_systems['webform'])) {
      $mail_systems['webform'] = 'MimeMailSystem';
      variable_set('mail_system', $mail_systems);
    }
  }

That way, the setting is stored in the DB. I'd also suggest a DSM to say "The default mail system for webform has been set to mimemail".

The benefit of this approach is transparency and the fact that the mail system module will show the setting from the off - so you can quickly tell that webform is an exception that needs to be dealt with!

Comments

quicksketch’s picture

I agree it'd be good to explicitly set the variables for Mail System. I think the use of $conf is sort of a left-over from the D6 port, and at the time I didn't understand the mail system variables (honestly it's still pretty unclear). We could probably use hook_install() (for the initial install) and hook_module_enable() (when other modules are enabled) to set the variable when the right modules are available.

quicksketch’s picture

Version: 7.x-3.x-dev » 7.x-4.x-dev
Issue summary: View changes

Moving this to 4.x. Not sure if this is still a serious problem now that we support Mandrill directly: #2030479: Support Mandrill (and other HTML-capable mail systems via _alter hook).

DanChadwick’s picture

Status: Active » Closed (won't fix)

I think this issue is now moot. That said, webform goes to a lot of effort to magically send HTML e-mails. I think there is probably a better way, such as relying on the mailsystem module. But that's a somewhat different issue.