Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I tested the module in its configuration settings, I've got a series of this type of messages:
Deprecated function: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in html2text->_convert() (line 424 of ...\swiftmailer\includes\classes\html2text.inc).
while the test message was sent successfully. There was a brief discussion on a similar issue here.
Comment | File | Size | Author |
---|---|---|---|
#10 | swiftmailer-deprecated-function-preg_replace-2190687-10.patch | 12.35 KB | B-Prod |
#3 | swiftmailer-deprecated-function-preg_replace-html2text-2190687-3.patch | 21.18 KB | B-Prod |
Comments
Comment #1
almc CreditAttribution: almc commentedI seem to have resolved this issue by replacement of the library included with this module, as it might be obsolete:
.../swiftmailer/includes/classes/html2text.inc
I've replaced this file with its current version from PHPMailer: https://github.com/PHPMailer/PHPMailer/blob/master/extras/class.html2tex...
The PHP warning about preg_replace() has gone after this replacement.
Could you please confirm if this is a legitimate replacement without possible side effects?
Comment #2
B-Prod CreditAttribution: B-Prod commentedThe PHPMailer library does not include the file you speak about anymore...
Why not using an external library like https://github.com/mtibben/html2text ?
This library has been updated so it does not use the \e modifier (for security and compatibility reasons) and is licensed under Eclipse Public Licence.
Comment #3
B-Prod CreditAttribution: B-Prod commentedMoreover, the Swiftmailer module relies on the Mail System module, which povides a function to convert HTML to text :
mailsystem_html_to_text()
.Here is a patch that fixes this issue using the function provided by Mail System module.
Comment #4
sbrattla CreditAttribution: sbrattla commentedHi,
I took the path which leans towards your comment #2 : I've upgraded the html2text library. I could use the mailsystem_html_to_text() function, but would you not assume that the html2text library is more comprehensive than the function which mailsystem_html_to_text() use?
The latest dev version can be pulled to test this.
Comment #5
sbrattla CreditAttribution: sbrattla commentedComment #6
B-Prod CreditAttribution: B-Prod commentedI agree the html2text library could lead to better results than the
mailsystem_html_to_text()
function.The possible ways to go are:
Let me know what seems the better option and if you need some help for setting the third option up if this is your preference.
Comment #7
B-Prod CreditAttribution: B-Prod commentedSome answer on this? Which option is the way to go?
Comment #8
sbrattla CreditAttribution: sbrattla as a volunteer commented3 seems to be a good way to go. No use in going with a deprecated/inactive library. However, that requires more time from my behalf. Not sure if I can get time to do that within a reasonable amount of time.
Comment #9
B-Prod CreditAttribution: B-Prod commentedI will take care of this.
Comment #10
B-Prod CreditAttribution: B-Prod commentedHere is the commit related to HTML2TEXT update:
http://cgit.drupalcode.org/swiftmailer/commit/?id=26e270b0baea88a85393e0...
And above the patch that follows #8
Comment #12
B-Prod CreditAttribution: B-Prod commentedTested with the various options, all works as expected.
The plain text conversions differs between Mail System and Html2Text, which provides more advanced theming.
Comment #13
B-Prod CreditAttribution: B-Prod commentedComment #15
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedComment #16
webflo CreditAttribution: webflo at UEBERBIT GmbH commentedCould not find an usages of the modifier in the D8 version.