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)
$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
// 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
// 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.
// 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.
// 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);
$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);
$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<>'
'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',
--- /dev/null
+<?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