Hi guys,
Following up with the support request #2207357: Interoperable with Mail System and HTML Mail? in the Reroute Email tracker, it would be great if any users of HTML Mail / Mail System could report back on testing with Reroute Email:
ie. If I installed HTML Mail and used Mail System to swap it out as the default mailer, would Reroute Email still intercept and reroute these emails?
I'm not very familiar with HTML Mail and Mail System, but from what I've seen in the code, they would still seem to be using Drupal Mail API, implementing hook_mail and not directly using PHP mail functions.
So I would assume they should be compatible with Reroute Email (which implements hook_mail_alter), but would greatly appreciate more feedback and details.
Could anybody please provide more information or testing/reporting of using the Reroute Email module with HTML Mail and Mail System?
Feel free to let me know if you would have any questions, comments or concerns on this ticket, I would certainly be glad to provide more information or explain in further details.
Thanks to all in advance for your great help testing, reviewing, reporting, questions, comments and feedbacks.
Cheers!
Comments
Comment #1
David Hernández CreditAttribution: David Hernández commentedFirst of all, we need to understand how Drupal sends e-mails:
Drupal can handle multiple systems to send mails. There is a system variable (variable_get('mail_system') with the enabled systems to send e-mails. By default, there is only one, called DefaultMailSystem ( https://api.drupal.org/api/drupal/modules%21system%21system.mail.inc/cla... ). Those "systems" are classes that implement a default interface called MailSystemInterface ( https://api.drupal.org/api/drupal/includes%21mail.inc/interface/MailSyst... ).
This interface only requires two functions: format and mail. The first one handles the formating and the second one, sends it.
So, what causes your problem?
If you implement a mail system, you have to implement both methods, the format and the mail function. The HTML Mail module actually "only needs" to do the formating, meanwhile Reroute Email "only needs" the sending part. HTML Mail doesn't know that you have another system to send e-mails and Reroute Email doesn't know that you have another system to format the e-mails.
Is there a solution for this?
Yes, there is. You can implement your own MailSystemInterface in a custom class that does the formating of HTML Mail and the sending of Reroute Email. If you don't want to do this, the Mail System module has a functionality that does it for you.
Just go to admin/config/system/mailsystem and under "New Class" select for the format method the HTML Mail and for the mail method the Reroute Email and save the settings. This will generate a new class, called HTMLMailSystem__RerouteEmailSystem or something like that.
Comment #2
David Hernández CreditAttribution: David Hernández commentedOk, nevermind, just reviewed how Reroute Email works and doesn't implement it's own class. Sorry, I should have read better the issue description.
In the hook_mail_alter of the reroute_email module, there is only one place where the $message['to'] is altered, to reroute the e-mail:
So, unless the if condition is not being applied, I don't see why the reroute_email will not work with HTMLMail.
I'm trying this, to see what's going on.
Comment #3
David Hernández CreditAttribution: David Hernández commentedI should have started here:
Installed HTML Mail and Reroute Email. Enabled both modules, tried the send test email from html mail at admin/config/system/htmlmail/test
Can someone else verify that it works correctly?
Comment #4
David Hernández CreditAttribution: David Hernández commentedComment #5
salvisNo patch and not sufficient interest, sorry...