joe92 Posted December 6, 2011 Share Posted December 6, 2011 I am setting up PHPMailer to send pdf's from my server and I have just come into the following error: Deprecated: Function set_magic_quotes_runtime() is deprecated in /var/www/PHPMailer_v5.1/class.phpmailer.php on line 1471 Deprecated: Function set_magic_quotes_runtime() is deprecated in /var/www/PHPMailer_v5.1/class.phpmailer.php on line 1475 The code in question is this (I've pointed out the lines mentioned above): <?php /** * Encodes attachment in requested format. * Returns an empty string on failure. * @param string $path The full path to the file * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' * @see EncodeFile() * @access private * @return string */ private function EncodeFile($path, $encoding = 'base64') { try { if (!is_readable($path)) { throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); } if (function_exists('get_magic_quotes')) { function get_magic_quotes() { return false; } } if (PHP_VERSION < 6) { $magic_quotes = get_magic_quotes_runtime(); set_magic_quotes_runtime(0); //<-- Here } $file_buffer = file_get_contents($path); $file_buffer = $this->EncodeString($file_buffer, $encoding); if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); } //<-- Here return $file_buffer; } catch (Exception $e) { $this->SetError($e->getMessage()); return ''; } } So my question is, how can I get rid of this error? How should I best edit this function to no longer use the deprecated set_magic_quotes_runtime? Any help is appreciated, Joe Quote Link to comment https://forums.phpfreaks.com/topic/252592-phpmailer-and-set_magic_quotes_runtime/ Share on other sites More sharing options...
Pikachu2000 Posted December 6, 2011 Share Posted December 6, 2011 set_magic_quotes_runtime was officially deprecated as of PHP version 5.3, so changing the version check should take care of it. if( PHP_VERSION < 5.3 ) { Quote Link to comment https://forums.phpfreaks.com/topic/252592-phpmailer-and-set_magic_quotes_runtime/#findComment-1294974 Share on other sites More sharing options...
joe92 Posted December 6, 2011 Author Share Posted December 6, 2011 Cheers! That's sorted it Quote Link to comment https://forums.phpfreaks.com/topic/252592-phpmailer-and-set_magic_quotes_runtime/#findComment-1294977 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.