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
Comments
Comment #1
quicksketchThanks for the report. I'll try updating MIMEMail and see what the result is.
Comment #2
ruslan.muradov CreditAttribution: ruslan.muradov commentedHi 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!
Comment #3
areineke CreditAttribution: areineke commentedPatch should detect and use the MailSystemInterface class set by the Mail System module, if it contains 'HTMLMailSystem' or 'MimeMailSystem'
Comment #4
quicksketchThanks @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.
Comment #6
quicksketchI'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.
Comment #7
quicksketchThis patch makes the "MimeMailSystem__SmtpMailSystem" class work with Webform 7.x-4.x. Committed this patch also.
Comment #9
areineke CreditAttribution: areineke commentedI'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:
Tested against MimeMailSystem__SmtpMailSystem, MimeMailSystem, SmtpMailSystem, and empty. All resulted in expected behavior (true/MimeMailSystem__SmtpMailSystem, true/MimeMailSystem, false, true/MimeMailSystem).
Sorry quicksketch!
Comment #11
quicksketchThanks for the followup @areineke. I'll take another (closer) look soon.
Comment #12
quicksketchI 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.
Comment #14
fenstratNeeds porting to 8.x-4.x.
Comment #15
fenstratCommitted and pushed 5f386eb to 8.x-4.x. Thanks!