Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
Pages: 1
Hi,
I got the following error message when trying to send an email:
Something went wrong
preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in PHPMailer.php on line 1442
Did Backlight shoot itself in the foot ? :-)
Should I modify the source code myself as indicated?
Patrick
Offline
Hi Patrick, it looks like PHPMailer (third party code shipped with Backlight) is using functions that are no longer compatible with your server. This fix unfortunately involves updating several lines of code. If you're keen to try it let me know and I'll advise where to change the code.
For the longer term, I will need to look at updating PHPMailer in our code base.
Offline
Hi Patrick, great. Can you try swapping out the method "function encodeQ" in backlight/lib/framework/PHPMailer.php with that from the latest version at https://github.com/PHPMailer/PHPMailer/ … mailer.php
I suggest renaming the old method to something like function encodeQ_old and adding the new version after it so that the change can be easily reversed if needed. The full function is pasted here:
public function encodeQ($str, $position = 'text')
{
// There should not be any EOL in the string
$pattern = '';
$encoded = str_replace(array("\r", "\n"), '', $str);
switch (strtolower($position)) {
case 'phrase':
// RFC 2047 section 5.3
$pattern = '^A-Za-z0-9!*+\/ -';
break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'comment':
// RFC 2047 section 5.2
$pattern = '\(\)"';
// intentional fall-through
// for this reason we build the $pattern without including delimiters and []
case 'text':
default:
// RFC 2047 section 5.1
// Replace every high ascii, control, =, ? and _ characters
$pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern;
break;
}
$matches = array();
if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) {
// If the string contains an '=', make sure it's the first thing we replace
// so as to avoid double-encoding
$eqkey = array_search('=', $matches[0]);
if (false !== $eqkey) {
unset($matches[0][$eqkey]);
array_unshift($matches[0], '=');
}
foreach (array_unique($matches[0]) as $char) {
$encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded);
}
}
// Replace every spaces to _ (more readable than =20)
return str_replace(' ', '_', $encoded);
}
Offline
Thanks for confirming Patrick. I have made the same change in our codebase, to be part of the next maintenance update.
Offline
Pages: 1