/**
  * @test
  */
 public function mailCallsHook()
 {
     $to = '*****@*****.**';
     $subject = 'Good news everybody!';
     $messageBody = 'The hooks works!';
     $additionalHeaders = 'Reply-to: jane@example.com';
     $additionalParameters = '-f postmaster@example.com';
     $mockMailer = $this->getMock('mockMailer', array('mail'));
     $mockMailer->expects($this->once())->method('mail')->with(array('to' => $to, 'subject' => $subject, 'messageBody' => $messageBody, 'additionalHeaders' => $additionalHeaders, 'additionalParameters' => $additionalParameters), FALSE);
     $GLOBALS['T3_VAR']['callUserFunction']['mockMailer->mail'] = array('obj' => $mockMailer, 'method' => 'mail');
     $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] = array('mockMailer->mail');
     t3lib_utility_Mail::mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
 }
 /**
  * Logs message to the system log.
  * This should be implemented around the source code, including the Core and both frontend and backend, logging serious errors.
  * If you want to implement the sysLog in your applications, simply add lines like:
  *		 tx_div2007_div::sysLog('[write message in English here]', 'extension_key', 'severity');
  *
  * @param string $msg Message (in English).
  * @param string $extKey Extension key (from which extension you are calling the log) or "Core"
  * @param integer $severity Severity: 0 is info, 1 is notice, 2 is warning, 3 is error, 4 is fatal error
  * @return void
  */
 public static function sysLog($msg, $extKey, $severity = 0)
 {
     $severity = tx_div2007_core::intInRange($severity, 0, 4);
     // is message worth logging?
     if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel']) > $severity) {
         return;
     }
     // initialize logging
     if (!$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit']) {
         self::initSysLog();
     }
     // do custom logging
     if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
         $params = array('msg' => $msg, 'extKey' => $extKey, 'backTrace' => debug_backtrace(), 'severity' => $severity);
         $fakeThis = FALSE;
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
             self::callUserFunction($hookMethod, $params, $fakeThis);
         }
     }
     // TYPO3 logging enabled?
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog']) {
         return;
     }
     $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
     $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
     // use all configured logging options
     foreach (explode(';', $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'], 2) as $log) {
         list($type, $destination, $level) = explode(',', $log, 4);
         // is message worth logging for this log type?
         if (intval($level) > $severity) {
             continue;
         }
         $msgLine = ' - ' . $extKey . ': ' . $msg;
         // write message to a file
         if ($type == 'file') {
             $lockObject = self::makeInstance('t3lib_lock', $destination, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']);
             /** @var t3lib_lock $lockObject */
             $lockObject->setEnableLogging(FALSE);
             $lockObject->acquire();
             $file = fopen($destination, 'a');
             if ($file) {
                 fwrite($file, date($dateFormat . ' ' . $timeFormat) . $msgLine . LF);
                 fclose($file);
                 self::fixPermissions($destination);
             }
             $lockObject->release();
         } elseif ($type == 'mail') {
             list($to, $from) = explode('/', $destination);
             if (!self::validEmail($from)) {
                 $from = t3lib_utility_Mail::getSystemFrom();
             }
             /** @var $mail t3lib_mail_Message */
             $mail = self::makeInstance('t3lib_mail_Message');
             $mail->setTo($to)->setFrom($from)->setSubject('Warning - error in TYPO3 installation')->setBody('Host: ' . $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . LF . 'Extension: ' . $extKey . LF . 'Severity: ' . $severity . LF . LF . $msg);
             $mail->send();
         } elseif ($type == 'error_log') {
             error_log($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . $msgLine, 0);
         } elseif ($type == 'syslog') {
             $priority = array(LOG_INFO, LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT);
             syslog($priority[(int) $severity], $msgLine);
         }
     }
 }
Пример #3
0
 /**
  * Logs message to the system log.
  * This should be implemented around the source code, including the Core and both frontend and backend, logging serious errors.
  * If you want to implement the sysLog in your applications, simply add lines like:
  * 		t3lib_div::sysLog('[write message in English here]', 'extension_key', 'severity');
  *
  * @param	string		Message (in English).
  * @param	string		Extension key (from which extension you are calling the log) or "Core"
  * @param	integer		Severity: 0 is info, 1 is notice, 2 is warning, 3 is error, 4 is fatal error
  * @return	void
  */
 public static function sysLog($msg, $extKey, $severity = 0)
 {
     global $TYPO3_CONF_VARS;
     $severity = self::intInRange($severity, 0, 4);
     // is message worth logging?
     if (intval($TYPO3_CONF_VARS['SYS']['systemLogLevel']) > $severity) {
         return;
     }
     // initialize logging
     if (!$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit']) {
         self::initSysLog();
     }
     // do custom logging
     if (isset($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']) && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
         $params = array('msg' => $msg, 'extKey' => $extKey, 'backTrace' => debug_backtrace(), 'severity' => $severity);
         $fakeThis = FALSE;
         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
             self::callUserFunction($hookMethod, $params, $fakeThis);
         }
     }
     // TYPO3 logging enabled?
     if (!$TYPO3_CONF_VARS['SYS']['systemLog']) {
         return;
     }
     $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
     $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
     // use all configured logging options
     foreach (explode(';', $TYPO3_CONF_VARS['SYS']['systemLog'], 2) as $log) {
         list($type, $destination, $level) = explode(',', $log, 4);
         // is message worth logging for this log type?
         if (intval($level) > $severity) {
             continue;
         }
         $msgLine = ' - ' . $extKey . ': ' . $msg;
         // write message to a file
         if ($type == 'file') {
             $file = fopen($destination, 'a');
             if ($file) {
                 flock($file, LOCK_EX);
                 // try locking, but ignore if not available (eg. on NFS and FAT)
                 fwrite($file, date($dateFormat . ' ' . $timeFormat) . $msgLine . LF);
                 flock($file, LOCK_UN);
                 // release the lock
                 fclose($file);
             }
         } elseif ($type == 'mail') {
             list($to, $from) = explode('/', $destination);
             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 . LF . $msg, $from ? 'From: ' . $from : '');
         } elseif ($type == 'error_log') {
             error_log($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . $msgLine, 0);
         } elseif ($type == 'syslog') {
             $priority = array(LOG_INFO, LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT);
             syslog($priority[(int) $severity], $msgLine);
         }
     }
 }
 /**
  * Sends the mail by calling the mail() function in php. On Linux systems this will invoke the MTA
  * defined in php.ini (sendmail -t -i by default), on Windows a SMTP must be specified in the sys.ini.
  * Most common MTA's on Linux has a Sendmail interface, including Postfix and Exim.
  * For setting the return-path correctly, the parameter -f has to be added to the system call to sendmail.
  * This obviously does not have any effect on Windows, but on Sendmail compliant systems this works. If safe mode
  * is enabled, then extra parameters is not allowed, so a safe mode check is made before the mail() command is
  * invoked. When using the -f parameter, some MTA's will put an X-AUTHENTICATION-WARNING saying that
  * the return path was modified manually with the -f flag. To disable this warning make sure that the user running
  * Apache is in the /etc/mail/trusted-users table.
  *
  * POSTFIX: With postfix version below 2.0 there is a problem that the -f parameter can not be used in conjunction
  * with -t. Postfix will give an error in the maillog:
  *
  *  cannot handle command-line recipients with -t
  *
  * The -f parameter is only enabled if the parameter forceReturnPath is enabled in the install tool.
  *
  * This whole problem of return-path turns out to be quite tricky. If you have a solution that works better, on all
  * standard MTA's then we are very open for suggestions.
  *
  * With time this function should be made such that several ways of sending the mail is possible (local MTA, smtp other).
  *
  * @return	boolean		Returns whether the mail was sent (successfully accepted for delivery)
  */
 public function sendTheMail()
 {
     $mailWasSent = FALSE;
     // Sending the mail requires the recipient and message to be set.
     if (!trim($this->recipient) || !trim($this->message)) {
         return FALSE;
     }
     // On windows the -f flag is not used (specific for Sendmail and Postfix),
     // but instead the php.ini parameter sendmail_from is used.
     $returnPath = $this->forceReturnPath && strlen($this->returnPath) > 0 ? '-f ' . escapeshellarg($this->returnPath) : '';
     if (TYPO3_OS == 'WIN' && $this->returnPath) {
         @ini_set('sendmail_from', t3lib_div::normalizeMailAddress($this->returnPath));
     }
     $recipient = t3lib_div::normalizeMailAddress($this->recipient);
     // 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 = !t3lib_utility_PhpOptions::isSafeModeEnabled() && $this->forceReturnPath;
     if ($returnPathPossible) {
         $mailWasSent = t3lib_utility_Mail::mail($recipient, $this->subject, $this->message, $this->headers, $returnPath);
     } else {
         $mailWasSent = t3lib_utility_Mail::mail($recipient, $this->subject, $this->message, $this->headers);
     }
     // Auto response
     if ($this->auto_respond_msg) {
         $theParts = explode('/', $this->auto_respond_msg, 2);
         $theParts[0] = str_replace('###SUBJECT###', $this->subject, $theParts[0]);
         $theParts[1] = str_replace("/", LF, $theParts[1]);
         $theParts[1] = str_replace("###MESSAGE###", $this->getContent('plain'), $theParts[1]);
         if ($returnPathPossible) {
             $mailWasSent = t3lib_utility_Mail::mail($this->from_email, $theParts[0], $theParts[1], 'From: ' . $recipient . $this->linebreak . $this->plain_text_header, $returnPath);
         } else {
             $mailWasSent = t3lib_utility_Mail::mail($this->from_email, $theParts[0], $theParts[1], 'From: ' . $recipient . $this->linebreak . $this->plain_text_header);
         }
     }
     if ($this->returnPath) {
         ini_restore('sendmail_from');
     }
     return $mailWasSent;
 }
 /**
  * Start function
  * This class is able to generate a mail in formmail-style from the data in $V
  * Fields:
  *
  * [recipient]:			email-adress of the one to receive the mail. If array, then all values are expected to be recipients
  * [attachment]:		....
  *
  * [subject]:			The subject of the mail
  * [from_email]:		Sender email. If not set, [email] is used
  * [from_name]:			Sender name. If not set, [name] is used
  * [replyto_email]:		Reply-to email. If not set [from_email] is used
  * [replyto_name]:		Reply-to name. If not set [from_name] is used
  * [organisation]:		Organization (header)
  * [priority]:			Priority, 1-5, default 3
  * [html_enabled]:		If mail is sent as html
  * [use_base64]:		If set, base64 encoding will be used instead of quoted-printable
  *
  * @param	array		Contains values for the field names listed above (with slashes removed if from POST input)
  * @param	boolean		Whether to base64 encode the mail content
  * @return	void
  */
 function start($valueList, $base64 = false)
 {
     $this->mailMessage = t3lib_div::makeInstance('t3lib_mail_Message');
     if ($GLOBALS['TSFE']->config['config']['formMailCharset']) {
         // Respect formMailCharset if it was set
         $this->characterSet = $GLOBALS['TSFE']->csConvObj->parse_charset($GLOBALS['TSFE']->config['config']['formMailCharset']);
     } elseif ($GLOBALS['TSFE']->metaCharset != $GLOBALS['TSFE']->renderCharset) {
         // Use metaCharset for mail if different from renderCharset
         $this->characterSet = $GLOBALS['TSFE']->metaCharset;
     }
     if ($base64 || $valueList['use_base64']) {
         $this->encoding = 'base64';
     }
     if (isset($valueList['recipient'])) {
         // convert form data from renderCharset to mail charset
         $this->subject = $valueList['subject'] ? $valueList['subject'] : 'Formmail on ' . t3lib_div::getIndpEnv('HTTP_HOST');
         $this->subject = $this->sanitizeHeaderString($this->subject);
         $this->fromName = $valueList['from_name'] ? $valueList['from_name'] : ($valueList['name'] ? $valueList['name'] : '');
         $this->fromName = $this->sanitizeHeaderString($this->fromName);
         $this->replyToName = $valueList['replyto_name'] ? $valueList['replyto_name'] : $this->fromName;
         $this->replyToName = $this->sanitizeHeaderString($this->replyToName);
         $this->organisation = $valueList['organisation'] ? $valueList['organisation'] : '';
         $this->organisation = $this->sanitizeHeaderString($this->organisation);
         $this->fromAddress = $valueList['from_email'] ? $valueList['from_email'] : ($valueList['email'] ? $valueList['email'] : '');
         if (!t3lib_div::validEmail($this->fromAddress)) {
             $this->fromAddress = t3lib_utility_Mail::getSystemFromAddress();
             $this->fromName = t3lib_utility_Mail::getSystemFromName();
         }
         $this->replyToAddress = $valueList['replyto_email'] ? $valueList['replyto_email'] : $this->fromAddress;
         $this->priority = $valueList['priority'] ? t3lib_div::intInRange($valueList['priority'], 1, 5) : 3;
         // auto responder
         $this->autoRespondMessage = trim($valueList['auto_respond_msg']) && $this->fromAddress ? trim($valueList['auto_respond_msg']) : '';
         if ($this->autoRespondMessage !== '') {
             // Check if the value of the auto responder message has been modified with evil intentions
             $autoRespondChecksum = $valueList['auto_respond_checksum'];
             $correctHmacChecksum = t3lib_div::hmac($this->autoRespondMessage);
             if ($autoRespondChecksum !== $correctHmacChecksum) {
                 t3lib_div::sysLog('Possible misuse of t3lib_formmail auto respond method. Subject: ' . $valueList['subject'], 'Core', 3);
                 return;
             } else {
                 $this->autoRespondMessage = $this->sanitizeHeaderString($this->autoRespondMessage);
             }
         }
         $plainTextContent = '';
         $htmlContent = '<table border="0" cellpadding="2" cellspacing="2">';
         // Runs through $V and generates the mail
         if (is_array($valueList)) {
             foreach ($valueList as $key => $val) {
                 if (!t3lib_div::inList($this->reserved_names, $key)) {
                     $space = strlen($val) > 60 ? LF : '';
                     $val = is_array($val) ? implode($val, LF) : $val;
                     // convert form data from renderCharset to mail charset (HTML may use entities)
                     $plainTextValue = $val;
                     $HtmlValue = htmlspecialchars($val);
                     $plainTextContent .= strtoupper($key) . ':  ' . $space . $plainTextValue . LF . $space;
                     $htmlContent .= '<tr><td bgcolor="#eeeeee"><font face="Verdana" size="1"><strong>' . strtoupper($key) . '</strong></font></td><td bgcolor="#eeeeee"><font face="Verdana" size="1">' . nl2br($HtmlValue) . '&nbsp;</font></td></tr>';
                 }
             }
         }
         $htmlContent .= '</table>';
         $this->plainContent = $plainTextContent;
         if ($valueList['html_enabled']) {
             $this->mailMessage->setBody($htmlContent, 'text/html');
             $this->mailMessage->addPart($plainTextContent, 'text/plain');
         } else {
             $this->mailMessage->setBody($plainTextContent, 'text/plain');
         }
         for ($a = 0; $a < 10; $a++) {
             $variableName = 'attachment' . ($a ? $a : '');
             if (!isset($_FILES[$variableName])) {
                 continue;
             }
             if (!is_uploaded_file($_FILES[$variableName]['tmp_name'])) {
                 t3lib_div::sysLog('Possible abuse of t3lib_formmail: temporary file "' . $_FILES[$variableName]['tmp_name'] . '" ("' . $_FILES[$variableName]['name'] . '") was not an uploaded file.', 'Core', 3);
             }
             if ($_FILES[$variableName]['tmp_name']['error'] !== UPLOAD_ERR_OK) {
                 t3lib_div::sysLog('Error in uploaded file in t3lib_formmail: temporary file "' . $_FILES[$variableName]['tmp_name'] . '" ("' . $_FILES[$variableName]['name'] . '") Error code: ' . $_FILES[$variableName]['tmp_name']['error'], 'Core', 3);
             }
             $theFile = t3lib_div::upload_to_tempfile($_FILES[$variableName]['tmp_name']);
             $theName = $_FILES[$variableName]['name'];
             if ($theFile && file_exists($theFile)) {
                 if (filesize($theFile) < $GLOBALS['TYPO3_CONF_VARS']['FE']['formmailMaxAttachmentSize']) {
                     $this->mailMessage->attach(Swift_Attachment::fromPath($theFile)->setFilename($theName));
                 }
             }
             $this->temporaryFiles[] = $theFile;
         }
         $from = $this->fromName ? array($this->fromAddress => $this->fromName) : array($this->fromAddress);
         $this->recipient = $this->parseAddresses($valueList['recipient']);
         $this->mailMessage->setSubject($this->subject)->setFrom($from)->setTo($this->recipient)->setPriority($this->priority);
         $replyTo = $this->replyToName ? array($this->replyToAddress => $this->replyToName) : array($this->replyToAddress);
         $this->mailMessage->addReplyTo($replyTo);
         $this->mailMessage->getHeaders()->addTextHeader('Organization', $this->organisation);
         if ($valueList['recipient_copy']) {
             $this->mailMessage->addCc($this->parseAddresses($valueList['recipient_copy']));
         }
         if ($this->characterSet) {
             $this->mailMessage->setCharset($this->characterSet);
         }
         // Ignore target encoding. This is handled automatically by Swift Mailer and overriding the defaults
         // is not worth the trouble
         // log dirty header lines
         if ($this->dirtyHeaders) {
             t3lib_div::sysLog('Possible misuse of t3lib_formmail: see TYPO3 devLog', 'Core', 3);
             if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG']) {
                 t3lib_div::devLog('t3lib_formmail: ' . t3lib_div::arrayToLogString($this->dirtyHeaders, '', 200), 'Core', 3);
             }
         }
     }
 }
 /**
  * Will send an email notification to warning_email_address/the login users email address when a login session is just started.
  * Depends on various parameters whether mails are send and to whom.
  *
  * @return	void
  * @access private
  */
 function emailAtLogin()
 {
     if ($this->loginSessionStarted) {
         // Send notify-mail
         $subject = 'At "' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '"' . ' from ' . t3lib_div::getIndpEnv('REMOTE_ADDR') . (t3lib_div::getIndpEnv('REMOTE_HOST') ? ' (' . t3lib_div::getIndpEnv('REMOTE_HOST') . ')' : '');
         $msg = sprintf('User "%s" logged in from %s (%s) at "%s" (%s)', $this->user['username'], t3lib_div::getIndpEnv('REMOTE_ADDR'), t3lib_div::getIndpEnv('REMOTE_HOST'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], t3lib_div::getIndpEnv('HTTP_HOST'));
         // Warning email address
         if ($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_email_addr']) {
             $warn = 0;
             $prefix = '';
             if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_mode']) & 1) {
                 // first bit: All logins
                 $warn = 1;
                 $prefix = $this->isAdmin() ? '[AdminLoginWarning]' : '[LoginWarning]';
             }
             if ($this->isAdmin() && intval($GLOBALS['TYPO3_CONF_VARS']['BE']['warning_mode']) & 2) {
                 // second bit: Only admin-logins
                 $warn = 1;
                 $prefix = '[AdminLoginWarning]';
             }
             if ($warn) {
                 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'], '@')) {
             t3lib_utility_Mail::mail($this->user['email'], $subject, $msg, $this->notifyHeader);
         }
     }
 }
 /**
  * Build and send warning email when new broken links were found.
  *
  * @param	string		$pageSections: Content of page section
  * @param	string		$modTS: TSconfig array
  * @return	bool		TRUE if mail was sent, FALSE if or not
  */
 protected function reportEmail($pageSections, $modTS)
 {
     $content = t3lib_parsehtml::substituteSubpart($this->templateMail, '###PAGE_SECTION###', $pageSections);
     /** @var array $markerArray */
     $markerArray = array();
     /** @var array $validEmailList */
     $validEmailList = array();
     /** @var boolean $sendEmail */
     $sendEmail = TRUE;
     $markerArray['totalBrokenLink'] = $this->totalBrokenLink;
     $markerArray['totalBrokenLink_old'] = $this->oldTotalBrokenLink;
     $content = t3lib_parsehtml::substituteMarkerArray($content, $markerArray, '###|###', TRUE, TRUE);
     /** @var t3lib_mail_Message $mail */
     $mail = t3lib_div::makeInstance('t3lib_mail_Message');
     if (empty($modTS['mail.']['fromemail'])) {
         $modTS['mail.']['fromemail'] = t3lib_utility_Mail::getSystemFromAddress();
     }
     if (empty($modTS['mail.']['fromname'])) {
         $modTS['mail.']['fromname'] = t3lib_utility_Mail::getSystemFromName();
     }
     if (t3lib_div::validEmail($modTS['mail.']['fromemail'])) {
         $mail->setFrom(array($modTS['mail.']['fromemail'] => $modTS['mail.']['fromname']));
     } else {
         throw new Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidFromEmail'), '1295476760');
     }
     if (t3lib_div::validEmail($modTS['mail.']['replytoemail'])) {
         $mail->setReplyTo(array($modTS['mail.']['replytoemail'] => $modTS['mail.']['replytoname']));
     }
     if (!empty($modTS['mail.']['subject'])) {
         $mail->setSubject($modTS['mail.']['subject']);
     } else {
         throw new Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.noSubject'), '1295476808');
     }
     if (!empty($this->email)) {
         $emailList = t3lib_div::trimExplode(',', $this->email);
         foreach ($emailList as $emailAdd) {
             if (!t3lib_div::validEmail($emailAdd)) {
                 throw new Exception($GLOBALS['LANG']->sL('LLL:EXT:linkvalidator/locallang.xml:tasks.error.invalidToEmail'), '1295476821');
             } else {
                 $validEmailList[] = $emailAdd;
             }
         }
     }
     if (is_array($validEmailList) && !empty($validEmailList)) {
         $mail->setTo($this->email);
     } else {
         $sendEmail = FALSE;
     }
     if ($sendEmail) {
         $mail->setBody($content, 'text/html');
         $mail->send();
     }
     return $sendEmail;
 }
 /**
  * Sends a notification email, reporting system issues.
  *
  * @param	array	$systemStatus Array of statuses
  */
 protected function sendNotificationEmail(array $systemStatus)
 {
     $systemIssues = array();
     foreach ($systemStatus as $statusProvider) {
         foreach ($statusProvider as $status) {
             if ($status->getSeverity() > tx_reports_reports_status_Status::OK) {
                 $systemIssues[] = (string) $status;
             }
         }
     }
     $subject = sprintf($GLOBALS['LANG']->getLL('status_updateTask_email_subject'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
     $message = sprintf($GLOBALS['LANG']->getLL('status_problemNotification'), '', '');
     $message .= CRLF . CRLF;
     $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_site') . ': ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
     $message .= CRLF . CRLF;
     $message .= $GLOBALS['LANG']->getLL('status_updateTask_email_issues') . ': ' . CRLF;
     $message .= implode(CRLF, $systemIssues);
     $message .= CRLF . CRLF;
     $from = t3lib_utility_Mail::getSystemFrom();
     $mail = t3lib_div::makeInstance('t3lib_mail_Message');
     $mail->setFrom($from);
     $mail->setTo($this->notificationEmail);
     $mail->setSubject($subject);
     $mail->setBody($message);
     $mail->send();
 }
    /**
     * Sends a warning to $email if there has been a certain amount of failed logins during a period.
     * If a login fails, this function is called. It will look up the sys_log to see if there has been more than $max failed logins the last $secondsBack seconds (default 3600). If so, an email with a warning is sent to $email.
     *
     * @param	string		Email address
     * @param	integer		Number of sections back in time to check. This is a kind of limit for how many failures an hour for instance.
     * @param	integer		Max allowed failures before a warning mail is sent
     * @return	void
     * @access private
     */
    function checkLogFailures($email, $secondsBack = 3600, $max = 3)
    {
        if ($email) {
            // get last flag set in the log for sending
            $theTimeBack = $GLOBALS['EXEC_TIME'] - $secondsBack;
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_log', 'type=255 AND action=4 AND tstamp>' . intval($theTimeBack), '', 'tstamp DESC', '1');
            if ($testRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                $theTimeBack = $testRow['tstamp'];
            }
            // Check for more than $max number of error failures with the last period.
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', 'type=255 AND action=3 AND error!=0 AND tstamp>' . intval($theTimeBack), '', 'tstamp');
            if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > $max) {
                // OK, so there were more than the max allowed number of login failures - so we will send an email then.
                $subject = 'TYPO3 Login Failure Warning (at ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ')';
                $email_body = '
There has been numerous attempts (' . $GLOBALS['TYPO3_DB']->sql_num_rows($res) . ') to login at the TYPO3
site "' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '" (' . t3lib_div::getIndpEnv('HTTP_HOST') . ').

This is a dump of the failures:

';
                while ($testRows = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                    $theData = unserialize($testRows['log_data']);
                    $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;
                }
                t3lib_utility_Mail::mail($email, $subject, $email_body, 'From: TYPO3 Login WARNING<>');
                $this->writelog(255, 4, 0, 3, 'Failure warning (%s failures within %s seconds) sent by email to %s', array($GLOBALS['TYPO3_DB']->sql_num_rows($res), $secondsBack, $email));
                // Logout written to log
            }
        }
    }