/** * Proxy for the PHP mail() function. Adds possibility to hook in and send the mails in a different way. * The hook can be used by adding function to the configuration array: * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] * * @param string $to Email address to send to. * @param string $subject Subject line, non-encoded. (see PHP function mail()) * @param string $messageBody Message content, non-encoded. (see PHP function mail()) * @param string $additionalHeaders Additional headers for the mail (see PHP function mail()) * @param string $additionalParameters Additional flags for the sending mail tool (see PHP function mail()) * @return boolean Indicates whether the mail has been sent or not * @see PHP function mail() [] * @link http://www.php.net/manual/en/function.mail.php * @deprecated since 6.1, will be removed two versions later - Use \TYPO3\CMS\Core\Mail\Mailer instead */ public static function mail($to, $subject, $messageBody, $additionalHeaders = NULL, $additionalParameters = NULL) { GeneralUtility::logDeprecatedFunction(); $success = TRUE; // If the mail does not have a From: header, fall back to the default in TYPO3_CONF_VARS. if (!preg_match('/^From:/im', $additionalHeaders) && $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']) { if (!is_null($additionalHeaders) && substr($additionalHeaders, -1) != LF) { $additionalHeaders .= LF; } if ($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']) { $additionalHeaders .= 'From: "' . $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'] . '" <' . $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'] . '>'; } else { $additionalHeaders .= 'From: ' . $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']; } } if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'])) { $parameters = array('to' => $to, 'subject' => $subject, 'messageBody' => $messageBody, 'additionalHeaders' => $additionalHeaders, 'additionalParameters' => $additionalParameters); $fakeThis = FALSE; foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] as $hookSubscriber) { $hookSubscriberContainsArrow = strpos($hookSubscriber, '->'); if ($hookSubscriberContainsArrow !== FALSE) { throw new \RuntimeException($hookSubscriber . ' is an invalid hook implementation. Please consider using an implementation of TYPO3\\CMS\\Core\\Mail\\MailerAdapter.', 1322287600); } else { $mailerAdapter = GeneralUtility::makeInstance($hookSubscriber); if ($mailerAdapter instanceof \TYPO3\CMS\Core\Mail\MailerAdapterInterface) { $success = $success && $mailerAdapter->mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters, $fakeThis); } else { throw new \RuntimeException($hookSubscriber . ' is not an implementation of TYPO3\\CMS\\Core\\Mail\\MailerAdapter, but must implement that interface to be used in the substituteMailDelivery hook.', 1294062286); } } } } else { if (is_null($additionalParameters)) { $success = @mail($to, $subject, $messageBody, $additionalHeaders); } else { $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters); } } if (!$success) { GeneralUtility::sysLog('Mail to "' . $to . '" could not be sent (Subject: "' . $subject . '").', 'Core', GeneralUtility::SYSLOG_SEVERITY_ERROR); } return $success; }
/** * Fixes the SQL mode by unsetting NO_BACKSLASH_ESCAPES if found. * * @return void */ private function setSqlMode() { $resource = $this->sql_query('SELECT @@SESSION.sql_mode;'); if ($resource) { $result = $resource->fetch_row(); if (isset($result[0]) && $result[0] && strpos($result[0], 'NO_BACKSLASH_ESCAPES') !== FALSE) { $modes = array_diff(GeneralUtility::trimExplode(',', $result[0]), array('NO_BACKSLASH_ESCAPES')); $query = 'SET sql_mode=\'' . $this->db->real_escape_string(implode(',', $modes)) . '\';'; $this->sql_query($query); GeneralUtility::sysLog('NO_BACKSLASH_ESCAPES could not be removed from SQL mode: ' . $this->sql_error(), 'rn_base', GeneralUtility::SYSLOG_SEVERITY_ERROR); } } }