1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-16 22:42:57 +02:00

Fix email problems on servers with PHP installations not accepting RFC-compliant subject string passed to the the mail()-function. (Bug )

git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10014 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen
2009-08-18 09:59:24 +00:00
parent 5ecc57b87e
commit 9bcc38ea0b
2 changed files with 33 additions and 11 deletions

@ -196,6 +196,7 @@
<li>[Fix] Prevent style switcher from blocking the tab key. (Bug #49335)</li>
<li>[Fix] Correctly redirect on MCP main page after posts approval/disapproval from it. (Bug #49625)</li>
<li>[Fix] Do not display topic approval status image for shadow topic if a user is not a moderator in the forum the topic has been moved to. (Bug #43295)</li>
<li>[Fix] Fix email problems on servers with PHP installations not accepting RFC-compliant subject string passed to the the mail()-function. (Bug #46725)</li>
<li>[Change] submit_post() now accepts force_approved_state key passed to $data to indicate new posts being approved (true) or unapproved (false).</li>
<li>[Change] Change the data format of the default file ACM to be more secure from tampering and have better performance.</li>
<li>[Change] Add index on log_time to the log table to prevent slowdown on boards with many log entries. (Bug #44665 - Patch by bantu)</li>

@ -390,7 +390,7 @@ class messenger
$headers[] = 'X-Priority: ' . $this->mail_priority;
$headers[] = 'X-MSMail-Priority: ' . (($this->mail_priority == MAIL_LOW_PRIORITY) ? 'Low' : (($this->mail_priority == MAIL_NORMAL_PRIORITY) ? 'Normal' : 'High'));
$headers[] = 'X-Mailer: PhpBB3';
$headers[] = 'X-Mailer: phpBB3';
$headers[] = 'X-MimeOLE: phpBB3';
$headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url());
@ -474,13 +474,7 @@ class messenger
}
else
{
// 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($this->eol, $headers);
ob_start();
$result = $config['email_function_name']($mail_to, mail_encode($this->subject, $this->eol), wordwrap(utf8_wordwrap($this->msg), 997, "\n", true), $headers);
$err_msg = ob_get_clean();
$result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, $this->eol, $err_msg);
}
if (!$result)
@ -723,9 +717,7 @@ class queue
}
else
{
ob_start();
$result = $config['email_function_name']($to, mail_encode($subject, $this->eol), wordwrap(utf8_wordwrap($msg), 997, "\n", true), implode($this->eol, $headers));
$err_msg = ob_get_clean();
$result = phpbb_mail($to, $subject, $msg, $headers, $this->eol, $err_msg);
}
if (!$result)
@ -1522,4 +1514,33 @@ function mail_encode($str, $eol = "\r\n")
return substr($str, 0, -strlen($delimiter));
}
/**
* Wrapper for sending out emails with the PHP's mail function
*/
function phpbb_mail($to, $subject, $msg, $headers, $eol, &$err_msg)
{
global $config;
// 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();
$result = $config['email_function_name']($to, mail_encode($subject, $eol), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
$err_msg = ob_get_clean();
// Try again...
// 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.
if (!$result)
{
// Use nothing as delimiter (results in SPACE used)
ob_start();
$result = $config['email_function_name']($to, mail_encode($subject, ''), wordwrap(utf8_wordwrap($msg), 997, "\n", true), $headers);
$err_msg = ob_get_clean();
}
return $result;
}
?>