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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

almc’s picture

I 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?

B-Prod’s picture

The 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.

B-Prod’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
21.18 KB

Moreover, 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.

sbrattla’s picture

Hi,

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.

sbrattla’s picture

Assigned: Unassigned » sbrattla
B-Prod’s picture

I agree the html2text library could lead to better results than the mailsystem_html_to_text() function.

The possible ways to go are:

  1. update the html2text which do not seem to be continued
  2. use the mailsystem_html_to_text function instead (patch #3)
  3. (2) by default, with the ability to switch to another library. This means a new hook, a new setting in the admin UI, and an implementation of the newly created hook to defines the options provided by Swiftmailer (so mailsystem and html2text)

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.

B-Prod’s picture

Some answer on this? Which option is the way to go?

sbrattla’s picture

3 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.

B-Prod’s picture

Assigned: sbrattla » B-Prod

I will take care of this.

B-Prod’s picture

Here is the commit related to HTML2TEXT update:
http://cgit.drupalcode.org/swiftmailer/commit/?id=26e270b0baea88a85393e0...

And above the patch that follows #8

  • 0623d7c committed on 7.x-1.x
    Issue #2190687 by almc, B-Prod: Deprecated function: preg_replace(): The...
B-Prod’s picture

Status: Needs review » Patch (to be ported)

Tested with the various options, all works as expected.
The plain text conversions differs between Mail System and Html2Text, which provides more advanced theming.

B-Prod’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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

webflo’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Closed (fixed) » Patch (to be ported)
webflo’s picture

Status: Patch (to be ported) » Fixed

Could not find an usages of the modifier in the D8 version.

Status: Fixed » Closed (fixed)

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