Advertisement
Guest User

t3lib_utility_Mail

a guest
Feb 11th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.46 KB | None | 0 0
  1. final class t3lib_utility_Mail {
  2.  
  3.         /**
  4.          * Proxy for the PHP mail() function. Adds possibility to hook in and send the mails in a different way.
  5.          * The hook can be used by adding function to the configuration array:
  6.          * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery']
  7.          *
  8.          * @param       string          Email address to send to.
  9.          * @param       string          Subject line, non-encoded. (see PHP function mail())
  10.          * @param       string          Message content, non-encoded. (see PHP function mail())
  11.          * @param       string          Additional headers for the mail (see PHP function mail())
  12.          * @param       string          Additional flags for the sending mail tool (see PHP function mail())
  13.          * @return      boolean         Indicates whether the mail has been sent or not
  14.          * @see         PHP function mail() []
  15.          * @link        http://www.php.net/manual/en/function.mail.php
  16.          */
  17.         public static function mail($to, $subject, $messageBody, $additionalHeaders = null, $additionalParameters = null) {
  18.                 $success = TRUE;
  19.                 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'])) {
  20.                         $parameters = array(
  21.                                 'to' => $to,
  22.                                 'subject' => $subject,
  23.                                 'messageBody' => $messageBody,
  24.                                 'additionalHeaders' => $additionalHeaders,
  25.                                 'additionalParameters' => $additionalParameters,
  26.                         );
  27.                         $fakeThis = FALSE;
  28.                         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] as $hookMethod) {
  29.                                 $success = $success && t3lib_div::callUserFunction($hookMethod, $parameters, $fakeThis);
  30.                         }
  31.                 } else {
  32.                         $success = @mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
  33.                 }
  34.  
  35.                 if (!$success) {
  36.                         t3lib_div::sysLog('Mail to "' . $to . '" could not be sent (Subject: "' . $subject . '").', 'Core', 3);
  37.                 }
  38.                 return $success;
  39.         }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement