Problem: Since update to version 7.x-3.20 webform was not able to send emails anymore.
Error message: "Unable to send e-mail. Contact the site administrator if the problem persists."
Setup: drupal7 + mailsystem + mimemail + smtp + webform

To integrate mimemail with smtp module you need to create a new Mime Mail module class, in my case MimeMailSystem__SmtpMailSystem.

The quickfix was for me to change line 3774 in file webform.module to this:

$enable = (!isset($mail_systems['webform']) || $mail_systems['webform'] == 'MimeMailSystem') ? 'MimeMailSystem__SmtpMailSystem' : FALSE;

after this change everything works fine

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Thanks for the report. I'll try updating MIMEMail and see what the result is.

ruslan.muradov’s picture

Hi there! I would like to say that I'am experiencing the same problem as the author of original post but with htmlmail module.
In my case I use HTMLMailSystem__SmtpMailSystem class for delivering emails on my site.
There is a check in webform_email_html_capable() on line 3778 (7.x-3.20) which checks for htmlmail module and whether HTMLMailSystem class is assigned to 'webform' component. It alters then the global $GLOBALS['conf']['mail_system'] at runtime which screw-ups the intended settings.
Can you please also look into this issue?

Thanks in advance!

areineke’s picture

Patch should detect and use the MailSystemInterface class set by the Mail System module, if it contains 'HTMLMailSystem' or 'MimeMailSystem'

quicksketch’s picture

Thanks @areineke! That looks like a great solution.

> It alters then the global $GLOBALS['conf']['mail_system'] at runtime which screw-ups the intended settings.

It looks like this patch solves this problem. Webform tries to check if MIMEMail (or HTMLMail) have explicit settings, and if so it leaves those settings in place.

  • Commit 10edece on 7.x-3.x by quicksketch:
    Issue #2200985 by areineke: New MIMEMail SMTP settings not recognized by...
quicksketch’s picture

Title: Issue with mimemail since last update » New MIMEMail SMTP settings not recognized by Webform

I've committed the patch in #3 to the 7.x-3.x branch of Webform. The 7.x-4.x version may also be affected by this in a different way. I'll revise the patch for that version shortly.

quicksketch’s picture

Status: Active » Fixed
FileSize
385 bytes

This patch makes the "MimeMailSystem__SmtpMailSystem" class work with Webform 7.x-4.x. Committed this patch also.

  • Commit 5f386eb on 7.x-4.x by quicksketch:
    Issue #2200985 by areineke: New MIMEMail SMTP settings not recognized by...
areineke’s picture

Status: Fixed » Needs review
FileSize
1.59 KB

I'm sorry - I just realized the patch from #3 will break in the case when MIME Mail (or HTML Mail) is installed, but the $mail_systems['webform'] is not explicitly set (by the Mail System Module or otherwise) i.e. !isset($mail_systems['webform'])

This patch (#9) should rectify that case. webform_email_html_capable() checks that:

  • $mail_systems['webform'] is set
  • If it is, check the setting to see if it contains a supported HTML e-mail module's MailSystemInterface class. If it doesn't, return false & do nothing. If it does, return true use $mail_systems['webform']
  • If $mail_systems['webform'] is not set, but a supported HTML e-mail module is installed, return true and use that module's MailSystemInterface class.

Tested against MimeMailSystem__SmtpMailSystem, MimeMailSystem, SmtpMailSystem, and empty. All resulted in expected behavior (true/MimeMailSystem__SmtpMailSystem, true/MimeMailSystem, false, true/MimeMailSystem).

Sorry quicksketch!

Status: Needs review » Needs work
quicksketch’s picture

Thanks for the followup @areineke. I'll take another (closer) look soon.

quicksketch’s picture

Status: Needs work » Fixed

I applied this patch today and confirmed that mails can be sent with/without HTML while MIME Mail is installed, before and after saving Mail System settings. Seems all good to me! Committed to 7.x-3.x branch only, since that's the only version affected by this problem.

  • Commit 6e87762 on 7.x-3.x by quicksketch:
    Issue #2200985 by areineke, quicksketch | danielkutik: New MIMEMail SMTP...
fenstrat’s picture

Version: 7.x-3.20 » 8.x-4.x-dev
Assigned: Unassigned » fenstrat
Status: Fixed » Patch (to be ported)

Needs porting to 8.x-4.x.

fenstrat’s picture

Version: 8.x-4.x-dev » 7.x-3.20
Assigned: fenstrat » Unassigned
Status: Patch (to be ported) » Fixed

Committed and pushed 5f386eb to 8.x-4.x. Thanks!

  • Commit 7047670 on 8.x-4.x by fenstrat:
    Issue #2200985 by areineke, quicksketch: New MIMEMail SMTP settings not...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.