Bug #23925
closedMail not sent with SAFE_MODE enabled
0%
Description
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.
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"
(issue imported from #M16231)
Files
Updated by Andreas Kießling about 14 years ago
Hi Boris,
nice catch :)
shouldn't then there be a check, if the script is running in safe mode?
You could log the attempt to send the mail with additional parameters to devlog then or even throw an exception.
Imagine you develop your site with safe mode off and, then move it to the production server over which you don't have control and which probably has safe mode... and you will face the problem again, but don't know what happened.
Regards,
Andreas
Updated by Boris Gulay about 14 years ago
There is such check, but one level up: in t3lib_htmlmail::sendTheMail. It check for safe mode enabled and, if it is, calls t3lib_utility_Mail::mail without last argument.
But t3lib_utility_Mail::mail always calls PHP mail with 5 arguments regardless of what value is passed to the last argument: default value of null (is case safe mode is enabled) or something meaningfull.
So, we don't need to do here something more than checking value of the last argument in t3lib_utility_Mail::mail. All safe mode aware logic is implemented in higher level functions.
Updated by Andreas Kießling about 14 years ago
You are right for t3lib_htmlmail, but that utility function is public and ment to be called from core / your extension, instead of calling mail() directly, so the hook substituteMailDelivery can be applied.
Updated by Boris Gulay about 14 years ago
Hmmm, OK.
So, what do you suggest? Check value of last argument inside t3lib_utility_Mail::mail, if it is not empty and safe mode is enabled, write warning message to TYPO3 log and ignore argument value (call PHP mail with 4 arguments)?
Updated by Andreas Kießling about 14 years ago
Yeah, that about sums it up.
Make your patch against svn trunk of 4.4 and use the newly introduced utility function to detect safe mode:
t3lib_utility_PhpOptions::isSafeModeEnabled that was introduced in rev. 9221
http://forge.typo3.org/projects/typo3v4-core/repository/revisions/9221
As for the logging: i'm not sure, but logs from core should probably only be done when enable_DLOG is set in the install tool.
Updated by Andreas Kießling about 14 years ago
Damn, that utility function was only comitted to trunk (4.5), not to 4.4.
There is already a bugreport here: http://bugs.typo3.org/view.php?id=15247 with a temporary solution for it as well with a patch for 4.4
Updated by Boris Gulay about 14 years ago
There are a lot of patches but none of them is accepted.
What is wrong with all of them?
Updated by Andreas Kießling about 14 years ago
There is nothing wrong with them, i just have not seen any of them in the core mailing list.
If you only put it at the bugtracker, someone might find the report and fixes it, but if you really want to get it in, have a look here: http://typo3.org/teams/core/core-mailinglist-rules/
Updated by Boris Gulay about 14 years ago
OK, let's make it right way.
I've added two new patches: one for 4.4 with warning message and one for trunk, that uses new function you mentioned.
Updated by Boris Gulay almost 14 years ago
This bug was posted to TYPO3-teams-core mailing list:
http://lists.typo3.org/pipermail/typo3-team-core/2010-November/045250.html