Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecated: preg_replace(): The /e modifier is deprecated in phpmailer

Tags:

php

phpmailer

I am using class.phpmailer.php to send email from my local server, it's processing well in my local server with PHP version php5.3.4 but after I update PHP version to 5.5.4 it's showing the following message:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in class.phpmailer.php`

This is the line causing the error:

$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', "'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded);
like image 793
koe Avatar asked Jul 24 '14 06:07

koe


1 Answers

Try and Replace:

This

$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',"'='.sprintf('%02X', ord(stripslashes('\\1')))", $encoded);

With

$encoded = preg_replace_callback('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/',function($m) { return '='.sprintf('%02X', ord(stripslashes($m[1]))); }, $encoded);
like image 107
Samosa Avatar answered Oct 17 '22 09:10

Samosa