aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2009-08-18 09:59:24 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2009-08-18 09:59:24 +0000
commit9bcc38ea0b9a9b2a97b3032c9a528fe8fba0719a (patch)
tree0fe72c795341f807706c1b6b0e799ec37fe48339 /phpBB
parent5ecc57b87e0444c355574b61538c08a4a1c66aad (diff)
downloadforums-9bcc38ea0b9a9b2a97b3032c9a528fe8fba0719a.tar
forums-9bcc38ea0b9a9b2a97b3032c9a528fe8fba0719a.tar.gz
forums-9bcc38ea0b9a9b2a97b3032c9a528fe8fba0719a.tar.bz2
forums-9bcc38ea0b9a9b2a97b3032c9a528fe8fba0719a.tar.xz
forums-9bcc38ea0b9a9b2a97b3032c9a528fe8fba0719a.zip
Fix email problems on servers with PHP installations not accepting RFC-compliant subject string passed to the the mail()-function. (Bug #46725)
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10014 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/docs/CHANGELOG.html1
-rw-r--r--phpBB/includes/functions_messenger.php43
2 files changed, 33 insertions, 11 deletions
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 958b58de40..ce3aa87906 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -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>
diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php
index 9b9c013a02..ecd9709f00 100644
--- a/phpBB/includes/functions_messenger.php
+++ b/phpBB/includes/functions_messenger.php
@@ -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;
+}
+
?> \ No newline at end of file