[TYPO3-core] RFC #16231: Bug: mail not sent if safe mode is on
Boris Gulay
boris at boressoft.ru
Tue Nov 9 11:01:18 CET 2010
This is an SVN patch request.
Type: Bugfix
Bugtracker references:
http://bugs.typo3.org/view.php?id=16231
http://bugs.typo3.org/view.php?id=15247
Branches:
TYPO3 4.4 and trunk.
Problem:
After upgrading to branch 4 of TYPO3 (from 4.3) I found that mail from
TYPO3 is not sent any more. Some of my extensions are using htmlmail
and
none of them is able to send messages: function sendTheMail always
returns false. I'm unable to send mail even from InstallTool.
I'm using TYPO3 4.4.4 on PHP 5.2.11 as FastCGI with nginx 0.8.52. Safe
mode is enabled.
Solution:
After some investigation I found where the problem is. In branch 4
htmlmail does not call PHP mail function directly anymore, instead it
uses new function in new class t3lib_utility_Mail::mail (there was no
such class in branch 3). Inside it PHP mail function is called, always
with 5 arguments, even if safe mode is on (in this case null is passed
as last argument).
But, in safe mode, PHP raises warning (see below) and mail function
returns false if you call mail function with 5 arguments, not regarding
to what is passed as as last parameter. In safe mode mail MUST NOT be
called with 5 arguments!
Here is a message PHP raises when mail is called with 5 arguments in
safe mode:
"Warning: mail(): SAFE MODE Restriction in effect. The fifth parameter
is disabled in SAFE MODE in Command line code on line 1"
Notes:
I've created two patches: one for 4.4 and one for trunk, that uses new
function to detect safe mode.
-------------- next part --------------
--- class.t3lib_utility_mail.php.bak 2010-11-08 20:52:35 +0300
+++ class.t3lib_utility_mail.php 2010-11-08 20:59:07 +0300
@@ -66,7 +66,16 @@
$success = $success && t3lib_div::callUserFunction($hookMethod, $parameters, $fakeThis);
}
} else {
- $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
+ if (ini_get('safe_mode') && !empty($additionalParameters))
+ {
+ t3lib_div::sysLog('Additional parameters to sendmail are not allowed if PHP safe mode is on.', 'Core', 2);
+ $additionalParameters = null;
+ }
+
+ if (empty($additionalParameters))
+ $success = @mail($to, $subject, $messageBody, $additionalHeaders);
+ else
+ $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
}
if (!$success) {
-------------- next part --------------
--- class.t3lib_utility_mail.php.bak 2010-11-08 20:52:35 +0300
+++ class.t3lib_utility_mail.php 2010-11-08 21:17:24 +0300
@@ -66,7 +66,16 @@
$success = $success && t3lib_div::callUserFunction($hookMethod, $parameters, $fakeThis);
}
} else {
- $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
+ if (t3lib_utility_PhpOptions::isSafeModeEnabled() && !empty($additionalParameters))
+ {
+ t3lib_div::sysLog('Additional parameters to sendmail are not allowed if PHP safe mode is on.', 'Core', 2);
+ $additionalParameters = null;
+ }
+
+ if (empty($additionalParameters))
+ $success = @mail($to, $subject, $messageBody, $additionalHeaders);
+ else
+ $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
}
if (!$success) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: not available
URL: <http://lists.typo3.org/pipermail/typo3-team-core/attachments/20101109/326b0bac/attachment.pgp>
More information about the TYPO3-team-core
mailing list