|
From: Meik S. <acy...@ph...> - 2009-08-18 10:00:11
|
Author: acydburn
Date: Tue Aug 18 10:59:24 2009
New Revision: 10014
Log:
Fix email problems on servers with PHP installations not accepting RFC-compliant subject string passed to the the mail()-function. (Bug #46725)
Modified:
branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html
branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php
Modified: branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html
==============================================================================
*** branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html (original)
--- branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html Tue Aug 18 10:59:24 2009
***************
*** 196,201 ****
--- 196,202 ----
<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>
Modified: branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php
==============================================================================
*** branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php (original)
--- branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php Tue Aug 18 10:59:24 2009
***************
*** 390,396 ****
$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-MimeOLE: phpBB3';
$headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url());
--- 390,396 ----
$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-MimeOLE: phpBB3';
$headers[] = 'X-phpBB-Origin: phpbb://' . str_replace(array('http://', 'https://'), array('', ''), generate_board_url());
***************
*** 474,486 ****
}
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();
}
if (!$result)
--- 474,480 ----
}
else
{
! $result = phpbb_mail($mail_to, $this->subject, $this->msg, $headers, $this->eol, $err_msg);
}
if (!$result)
***************
*** 723,731 ****
}
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();
}
if (!$result)
--- 717,723 ----
}
else
{
! $result = phpbb_mail($to, $subject, $msg, $headers, $this->eol, $err_msg);
}
if (!$result)
***************
*** 1522,1525 ****
--- 1514,1546 ----
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;
+ }
+
?>
\ No newline at end of file
|