Closed alanmels closed 1 year ago
Had to set all classes to Mime Mail on admin/config/system/mailsystem
as otherwise as explained on https://www.drupal.org/project/phpmailer/issues/1162666:
This happens because the Mimemail library sites/all/modules/mimemail/mimemail.inc is not loaded for other mail engines than Mimemail.
And here is the patch, even-though it's for another module PHPMailer. Not sure how to address this issue within the module, but I believe this issue should not be left to other modules to deal with.
https://www.drupal.org/files/issues/phpmailer.mimemail.inc_.2.patch:
diff --git a/phpmailer.module b/phpmailer.module
index 8ad2f2c..f545f6b 100644
--- a/phpmailer.module
+++ b/phpmailer.module
@@ -92,6 +92,9 @@ function phpmailer_mailengine($op, $message = array()) {
case 'single':
case 'send':
module_load_include('inc', 'phpmailer', 'includes/phpmailer.mimemail');
+ // Mimemail API does not load mimemail.inc for other mailengines; we rely
+ // on mimemail_rfc_headers(), so ensure that it is loaded.
+ module_load_include('inc', 'mimemail');
return mimemail_phpmailer_send($message);
}
}
Are you using https://github.com/backdrop-contrib/phpmailer then? And are you relying on mimemail's "mailengine" or are you using https://github.com/backdrop-contrib/mailsystem?
I'm using mailsystem, but reference to phpmailer was brought up just to point out the problem. In other words, Ubercart tried to do the same as PHPMailer did in the above example, that sending mail without relevant classes on admin/config/system/mailsystem
set to Mime Mail. As I said when I set all classes on admin/config/system/mailsystem
to Mime Mail the problem was gone.
So after careful looking at how PHPMailer took care of the problem I feel to close this issue as it feels that each module that needs to send mail has to implement the above hook_mailengine
. Unless there is a universal solution to include mimemail.inc
every time some contributed or custom module needs to send mail.
The current version of mimemail
for Drupal 7 includes a module_load_include('inc', 'mimemail');
at the top of mimemail_mailengine()
.
So I agree that this needs to be added to the Backdrop version as well. I'll create a PR.
PR #41. @alanmels, can you check if this solves your issue?
@argiepiano, I've just tested this and can confirm it resolves the issue. RTBC. Thanks!
Please also see that line https://git.drupalcode.org/project/mimemail/-/commit/69917dda3841acd49b46d2c7ee251ac8105b6d03#da85a78001e33cbb9d7b45485ffda112b0673afd_202_206 existed on Drupal 7 since it was ported from Drupal 6 11 years ago.
To replicate the error, enable Ubercart, create a product and complete checkout process and it will give:
Error: Call to undefined function mimemail_rfc_headers() in mimemail_mailengine() (line 256 of /var/www/html/docroot/modules/contrib/mimemail/mimemail.module).