Added Feature #13698: Add proxy for the mail() function (thanks to Tolleiv Nietsch)
authorSteffen Kamper <info@sk-typo3.de>
Tue, 13 Apr 2010 20:04:49 +0000 (20:04 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Tue, 13 Apr 2010 20:04:49 +0000 (20:04 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7349 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_beuserauth.php
t3lib/class.t3lib_div.php
t3lib/class.t3lib_htmlmail.php
t3lib/class.t3lib_userauthgroup.php
t3lib/core_autoload.php
t3lib/utility/class.t3lib_utility_mail.php [new file with mode: 0644]

index 09e1f47..b05f05c 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,7 @@
 
 2010-04-13  Steffen Kamper  <info@sk-typo3.de>
 
+       * Added Feature #13698: Add proxy for the mail() function (thanks to Tolleiv Nietsch)
        * Added Feature #13982: Feature: Renewal of the taskcenter Part III (thanks to Georg Ringer)
        * Added Feature #13982: Feature: Renewal of the taskcenter Part II (thanks to Georg Ringer)
        * Added Feature #13982: Feature: Renewal of the taskcenter Part I (thanks to Georg Ringer)
index bc58f1c..4a693f1 100644 (file)
@@ -345,7 +345,7 @@ class t3lib_beUserAuth extends t3lib_userAuthGroup {
                                        $prefix='[AdminLoginWarning]';
                                }
                                if ($warn)      {
-                                       mail($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'],
+                                       t3lib_utility_Mail::mail($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr'],
                                                $prefix.' '.$subject,
                                                $msg,
                                                $this->notifyHeader
@@ -355,7 +355,7 @@ class t3lib_beUserAuth extends t3lib_userAuthGroup {
 
                                // If An email should be sent to the current user, do that:
                        if ($this->uc['emailMeAtLogin'] && strstr($this->user['email'],'@'))    {
-                               mail($this->user['email'],
+                               t3lib_utility_Mail::mail($this->user['email'],
                                        $subject,
                                        $msg,
                                        $this->notifyHeader
index 73be877..ef95431 100644 (file)
@@ -5268,12 +5268,9 @@ final class t3lib_div {
                // So we stick to LF in all cases.
                $headers = trim(implode(LF, self::trimExplode(LF, $headers, true)));    // Make sure no empty lines are there.
 
-               $ret = @mail($email, $subject, $message, $headers);
-               if (!$ret)      {
-                       self::sysLog('Mail to "'.$email.'" could not be sent (Subject: "'.$subject.'").', 'Core', 3);
+
+               return t3lib_utility_Mail::mail($email, $subject, $message, $headers);
                }
-               return $ret;
-       }
 
        /**
         * Implementation of quoted-printable encode.
@@ -5563,7 +5560,7 @@ final class t3lib_div {
                                // send message per mail
                        elseif ($type == 'mail')        {
                                list($to,$from) = explode('/',$destination);
-                               mail($to, 'Warning - error in TYPO3 installation',
+                               t3lib_utility_Mail::mail($to, 'Warning - error in TYPO3 installation',
                                        'Host: '.$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'].LF.
                                        'Extension: '.$extKey.LF.
                                        'Severity: '.$severity.LF.
index 2f3a823..1d134f7 100644 (file)
@@ -734,13 +734,13 @@ class t3lib_htmlmail {
                // If safe mode is on, the fifth parameter to mail is not allowed, so the fix wont work on unix with safe_mode=On
                $returnPathPossible = (!ini_get('safe_mode') && $this->forceReturnPath);
                if ($returnPathPossible) {
-                       $mailWasSent = mail($recipient,
+                       $mailWasSent = t3lib_utility_Mail::mail($recipient,
                                  $this->subject,
                                  $this->message,
                                  $this->headers,
                                  $returnPath);
                } else {
-                       $mailWasSent = mail($recipient,
+                       $mailWasSent = t3lib_utility_Mail::mail($recipient,
                                  $this->subject,
                                  $this->message,
                                  $this->headers);
@@ -751,13 +751,13 @@ class t3lib_htmlmail {
                        $theParts = explode('/',$this->auto_respond_msg,2);
                        $theParts[1] = str_replace("/",LF,$theParts[1]);
                        if ($returnPathPossible) {
-                               $mailWasSent = mail($this->from_email,
+                               $mailWasSent = t3lib_utility_Mail::mail($this->from_email,
                                        $theParts[0],
                                        $theParts[1],
                                        'From: ' . $recipient,
                                        $returnPath);
                        } else {
-                               $mailWasSent = mail($this->from_email,
+                               $mailWasSent = t3lib_utility_Mail::mail($this->from_email,
                                        $theParts[0],
                                        $theParts[1],
                                        'From: ' . $recipient);
index 35b0822..66d65d1 100644 (file)
@@ -1811,7 +1811,7 @@ This is a dump of the failures:
                                        $email_body.= date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'].' '.$GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$testRows['tstamp']).':  '.@sprintf($testRows['details'],''.$theData[0],''.$theData[1],''.$theData[2]);
                                        $email_body.= LF;
                                }
-                               mail(   $email,
+                               t3lib_utility_Mail::mail($email,
                                        $subject,
                                        $email_body,
                                        'From: TYPO3 Login WARNING<>'
index ed1c953..87a120d 100644 (file)
@@ -124,6 +124,7 @@ return array(
        't3lib_tceforms_suggest_defaultreceiver' => PATH_t3lib . 'tceforms/class.t3lib_tceforms_suggest_defaultreceiver.php',
        't3lib_utility_client' => PATH_t3lib . 'utility/class.t3lib_utility_client.php',
        't3lib_utility_http' => PATH_t3lib . 'utility/class.t3lib_utility_http.php',
+       't3lib_utility_mail' => PATH_t3lib . 'utility/class.t3lib_utility_mail.php',
        'tslib_adminpanel' => PATH_tslib . 'class.tslib_adminpanel.php',
        'tslib_cobj' => PATH_tslib . 'class.tslib_content.php',
        'tslib_frameset' => PATH_tslib . 'class.tslib_content.php',
diff --git a/t3lib/utility/class.t3lib_utility_mail.php b/t3lib/utility/class.t3lib_utility_mail.php
new file mode 100644 (file)
index 0000000..8f0d48e
--- /dev/null
@@ -0,0 +1,78 @@
+<?php\r
+/***************************************************************\r
+ * Copyright notice\r
+ *\r
+ * (c) 2010 Tolleiv Nietsch <nietsch@aoemedia.de>\r
+ * All rights reserved\r
+ *\r
+ * This script is part of the TYPO3 project. The TYPO3 project is\r
+ * free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 2 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * The GNU General Public License can be found at\r
+ * http://www.gnu.org/copyleft/gpl.html.\r
+ * A copy is found in the textfile GPL.txt and important notices to the license\r
+ * from the author is found in LICENSE.txt distributed with these scripts.\r
+ *\r
+ *\r
+ * This script is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * This copyright notice MUST APPEAR in all copies of the script!\r
+ ***************************************************************/\r
+\r
+/**\r
+ * Class to handle mail specific functionality\r
+ *\r
+ * $Id: class.t3lib_utility_mail.php 6536 2009-11-25 14:07:18Z stucki $\r
+ *\r
+ *\r
+ * @author      Tolleiv Nietsch <nietsch@aoemedia.de>\r
+ * @package TYPO3\r
+ * @subpackage t3lib\r
+ */\r
+final class t3lib_utility_Mail {\r
+\r
+       /**\r
+        * Proxy for the PHP mail() function. Adds possibility to hook in and send the mails in a different way.\r
+        * The hook can be used by adding function to the configuration array:\r
+        * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substitudeMailDelivery']\r
+        *\r
+        * @param       string          Email address to send to.\r
+        * @param       string          Subject line, non-encoded. (see )\r
+        * @param       string          Message content, non-encoded. (see PHP function mail())\r
+        * @param       string          Additional headers for the mail (see PHP function mail())\r
+        * @param       string          Additional flags for the sending mail tool (see PHP function mail())\r
+        * @return      boolean         Indicates whether the mail has been sent or not\r
+        * @see         PHP function mail() []\r
+        * @link        http://www.php.net/manual/en/function.mail.php\r
+        */\r
+       public static function mail($to, $subject, $messageBody, $additionalHeaders = null, $additionalParameters = null) {\r
+               $success = TRUE;\r
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'])) {\r
+                       $parameters = array(\r
+                               'to' => $to,\r
+                               'subject' => $subject,\r
+                               'messageBody' => $messageBody,\r
+                               'additionalHeaders' => $additionalHeaders,\r
+                               'additionalParameters' => $additionalParameters,\r
+                       );\r
+                       $fakeThis = FALSE;\r
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] as $hookMethod)      {\r
+                               $success = $success && t3lib_div::callUserFunction($hookMethod, $parameters, $fakeThis);\r
+                       }\r
+               } else {\r
+                       $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);\r
+               }\r
+\r
+               if (!$success)  {\r
+                       t3lib_div::sysLog('Mail to "' . $email . '" could not be sent (Subject: "' . $subject . '").', 'Core', 3);\r
+               }\r
+               return $success;\r
+       }\r
+}\r
+?>\r