Error of: preg_replace_callback

Asked

Viewed 667 times

-1

Certain precise functionality of sending emails and before sent normally, however, now appears the following message:

Deprecated: preg_replace(): The /e Modifier is deprecated, use preg_replace_callback Instead in /srv/disk35/4754145/www/meusite.com/phpmailer/class.phpmailer.php on line 1922

How to solve this problem?

Below transcribe the excerpt from the file mentioned in the message:

// Replace every high ascii, control =, ? and _ characters
//TODO using /e (equivalent to eval()) is probably not a good idea
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
                        "'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded);
break;
  • 1

    preg_replace is deprecated since version 5.5 and not supported for php 7.0 version. You can change your error display settings in php.ini to not display deprecated if your version is below 7.0 or replace using the native function with : preg_replace_callback. The last solution is the one I give you. http://php.net/manual/en/function.preg-replace-callback.php

1 answer

1

Your code must be using an older version of PHP Mailer. Try updating it and make sure the error persists.

https://github.com/PHPMailer/PHPMailer

If you are using Composer:

composer update phpmailer/phpmailer

Browser other questions tagged

You are not signed in. Login or sign up in order to post.