mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Merge branch 'develop-olympus' into develop
* develop-olympus: [ticket/10245] Use error_collector instead of ob_start() and ob_get_clean().
This commit is contained in:
commit
d0f5b527fe
1 changed files with 21 additions and 5 deletions
|
@ -976,9 +976,16 @@ function smtpmail($addresses, $subject, $message, &$err_msg, $headers = false)
|
|||
$smtp->add_backtrace('Connecting to ' . $config['smtp_host'] . ':' . $config['smtp_port']);
|
||||
|
||||
// Ok we have error checked as much as we can to this point let's get on it already.
|
||||
ob_start();
|
||||
if (!class_exists('phpbb_error_collector'))
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
|
||||
}
|
||||
$collector = new phpbb_error_collector;
|
||||
$collector->install();
|
||||
$smtp->socket = fsockopen($config['smtp_host'], $config['smtp_port'], $errno, $errstr, 20);
|
||||
$error_contents = ob_get_clean();
|
||||
$collector->uninstall();
|
||||
$error_contents = $collector->format_errors();
|
||||
|
||||
if (!$smtp->socket)
|
||||
{
|
||||
|
@ -1609,18 +1616,27 @@ function mail_encode($str, $eol = "\r\n")
|
|||
*/
|
||||
function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg)
|
||||
{
|
||||
global $config;
|
||||
global $config, $phpbb_root_path, $phpEx;
|
||||
|
||||
// We use the EOL character for the OS here because the PHP mail function does not correctly transform line endings. On Windows SMTP is used (SMTP is \r\n), on UNIX a command is used...
|
||||
// Reference: http://bugs.php.net/bug.php?id=15841
|
||||
$headers = implode($eol, $headers);
|
||||
|
||||
ob_start();
|
||||
if (!class_exists('phpbb_error_collector'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
|
||||
}
|
||||
|
||||
$collector = new phpbb_error_collector;
|
||||
$collector->install();
|
||||
|
||||
// On some PHP Versions mail() *may* fail if there are newlines within the subject.
|
||||
// Newlines are used as a delimiter for lines in mail_encode() according to RFC 2045 section 6.8.
|
||||
// Because PHP can't decide what is wanted we revert back to the non-RFC-compliant way of separating by one space (Use '' as parameter to mail_encode() results in SPACE used)
|
||||
$result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
|
||||
$err_msg = ob_get_clean();
|
||||
|
||||
$collector->uninstall();
|
||||
$err_msg = $collector->format_errors();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue