Index: t3lib/config_default.php
===================================================================
--- t3lib/config_default.php (Revision 10226)
+++ t3lib/config_default.php (Revision 10227)
@@ -91,7 +91,7 @@
'setDBinit' => '-1', // String (textarea): Commands to send to database right after connecting, separated by newline. Ignored by the DBAL extension except for the 'native' type!
'dbClientCompress' => FALSE, // Boolean: if true, data exchange between TYPO3 and database server will be compressed. This may improve performance if (1) database serever is on the different server and (2) network connection speed to database server is 100mbps or less. CPU usage will be higher if this option is used but database operations will be executed faster due to much less (up to 3 times) database network traffic. This option has no effect if MySQL server is localhost.
'setMemoryLimit' => 0, // Integer: memory_limit in MB: If more than 16, TYPO3 will try to use ini_set() to set the memory limit of PHP to the value. This works only if the function ini_set() is not disabled by your sysadmin.
- 'forceReturnPath' => FALSE, // Boolean: Force return path to be applied in mail() calls. If this is set, all calls to mail() done by t3lib_htmlmail will be called with '-f<return_path> as the 5th parameter. This will make the return path correct on almost all Unix systems. There is a known problem with Postfix below version 2: Mails are not sent if this option is set and Postfix is used. On Windows platforms, the return path is set via a call to ini_set. This has no effect if safe_mode in PHP is on.
+ 'forceReturnPath' => FALSE, // Boolean: Note: This option is deprecated as of TYPO3 4.5 together with t3lib_htmlmail. This behaviour is the default using the new t3lib_mail methods. Force return path to be applied in mail() calls. If this is set, all calls to mail() done by t3lib_htmlmail will be called with '-f<return_path> as the 5th parameter. This will make the return path correct on almost all Unix systems. There is a known problem with Postfix below version 2: Mails are not sent if this option is set and Postfix is used. On Windows platforms, the return path is set via a call to ini_set. This has no effect if safe_mode in PHP is on.
'serverTimeZone' => 1, // Integer: GMT offset of servers time (from time()). Default is "1" which is "GMT+1" (central european time). This value can be used in extensions that are GMT aware and wants to convert times to/from other timezones.
'phpTimeZone' => '', // String: timezone to force for all date() and mktime() functions. A list of supported values can be found at php.net. If this is not set, a valid fallback will be searched for by PHP (php.ini's date.timezone setting, server defaults, etc); and if no fallback is found, the value of "UTC" is used instead.
'systemLog' => '', //
String: semi-colon separated list. Defines one or more logging methods. Possible methods:
file,<abs-path-to-file>[,<level>]
logs to a file
mail,<to>[/<from>][,<level>]
sends the log entries via mail
syslog,<facility>,[,<level>]
uses the operating system's log. Facility may be one of LOCAL0..LOCAL7, USER (on Windows USER is the only valid type).
';
- if ($V['html_enabled']) {
- $this->setHTML($this->encodeMsg($HTML_content));
+ $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');
}
- $this->addPlain($Plain_content);
for ($a = 0; $a < 10; $a++) {
- $varname = 'attachment' . (($a) ? $a : '');
- if (!isset($_FILES[$varname])) {
+ $variableName = 'attachment' . (($a) ? $a : '');
+ if (!isset($_FILES[$variableName])) {
continue;
}
- if (!is_uploaded_file($_FILES[$varname]['tmp_name'])) {
- t3lib_div::sysLog('Possible abuse of t3lib_formmail: temporary file "' . $_FILES[$varname]['tmp_name'] . '" ("' . $_FILES[$varname]['name'] . '") was not an uploaded file.', 'Core', 3);
+ 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[$varname]['tmp_name']['error'] !== UPLOAD_ERR_OK) {
- t3lib_div::sysLog('Error in uploaded file in t3lib_formmail: temporary file "' . $_FILES[$varname]['tmp_name'] . '" ("' . $_FILES[$varname]['name'] . '") Error code: ' . $_FILES[$varname]['tmp_name']['error'], '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[$varname]['tmp_name']);
- $theName = $_FILES[$varname]['name'];
+ $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->addAttachment($theFile, $theName);
+ $this->mailMessage->attach(Swift_Attachment::fromPath($theFile)->setFilename($theName));
}
}
- t3lib_div::unlink_tempfile($theFile);
+ $this->temporaryFiles[] = $theFile;
}
- $this->setHeaders();
- $this->setContent();
- $this->setRecipient($V['recipient']);
- if ($V['recipient_copy']) {
- $this->recipient_copy = trim($V['recipient_copy']);
+ $this->recipient = $valueList['recipient'];
+ $this->mailMessage->setSubject($this->subject)
+ ->setFrom(array($this->fromAddress => $this->fromName))
+ ->setTo($this->recipient)
+ ->setPriority($this->priority);
+ $this->mailMessage->getHeaders()->addTextHeader('Organization', $this->organisation);
+ if ($valueList['recipient_copy']) {
+ $this->mailMessage->addCc(trim($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);
@@ -203,51 +259,12 @@
}
/**
- * Adds an attachment to the mail
- *
- * @param string The absolute path to the file to add as attachment
- * @param string The files original filename (not necessarily the same as the current since this could be uploaded files...)
- * @return boolean True if the file existed and was added.
- * @access private
- */
- function addAttachment($file, $filename) {
- $content = $this->getURL($file); // We fetch the content and the mime-type
- $fileInfo = $this->split_fileref($filename);
- if ($fileInfo['fileext'] == 'gif') {
- $content_type = 'image/gif';
- }
- if ($fileInfo['fileext'] == 'bmp') {
- $content_type = 'image/bmp';
- }
- if ($fileInfo['fileext'] == 'jpg' || $fileInfo['fileext'] == 'jpeg') {
- $content_type = 'image/jpeg';
- }
- if ($fileInfo['fileext'] == 'html' || $fileInfo['fileext'] == 'htm') {
- $content_type = 'text/html';
- }
- if (!$content_type) {
- $content_type = 'application/octet-stream';
- }
-
- if ($content) {
- $theArr['content_type'] = $content_type;
- $theArr['content'] = $content;
- $theArr['filename'] = $filename;
- $this->theParts['attach'][] = $theArr;
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
-
- /**
* Checks string for suspicious characters
*
* @param string String to check
* @return string Valid or empty string
*/
- function sanitizeHeaderString($string) {
+ protected function sanitizeHeaderString($string) {
$pattern = '/[\r\n\f\e]/';
if (preg_match($pattern, $string) > 0) {
$this->dirtyHeaders[] = $string;
@@ -255,6 +272,50 @@
}
return $string;
}
+
+ /**
+ * Sends the actual mail and handles autorespond message
+ *
+ * @return boolean
+ */
+ public function sendTheMail() {
+
+ // Sending the mail requires the recipient and message to be set.
+ if (!$this->mailMessage->getTo() || !trim($this->mailMessage->getBody())) {
+ return FALSE;
+ }
+
+ $this->mailMessage->send();
+
+ // Auto response
+ if ($this->autoRespondMessage) {
+ $theParts = explode('/', $this->autoRespondMessage, 2);
+ $theParts[0] = str_replace('###SUBJECT###', $this->subject, $theParts[0]);
+ $theParts[1] = str_replace("/", LF, $theParts[1]);
+ $theParts[1] = str_replace("###MESSAGE###", $this->plainContent, $theParts[1]);
+
+ /** @var $autoRespondMail t3lib_mail_Message */
+ $autoRespondMail = t3lib_div::makeInstance('t3lib_mail_Message');
+ $autoRespondMail->setTo($this->fromAddress)
+ ->setSubject($theParts[0])
+ ->setFrom($this->recipient)
+ ->setBody($theParts[1]);
+ if ($this->returnPath) {
+ $autoRespondMail->setReturnPath($this->returnPath);
+ }
+ $autoRespondMail->send();
+ }
+ return $this->mailMessage->isSent();
+ }
+
+ /**
+ * Do some cleanup at the end (deleting attachment files)
+ */
+ public function __destruct() {
+ foreach ($this->temporaryFiles as $file) {
+ t3lib_div::unlink_tempfile($file);
+ }
+ }
}
@@ -262,4 +323,4 @@
include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_formmail.php']);
}
-?>
\ No newline at end of file
+?>
Index: t3lib/class.t3lib_userauthgroup.php
===================================================================
--- t3lib/class.t3lib_userauthgroup.php (Revision 10226)
+++ t3lib/class.t3lib_userauthgroup.php (Revision 10227)
@@ -1890,8 +1890,7 @@
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
+ $email_body = 'There have been some 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:
@@ -1902,11 +1901,14 @@
$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<>'
- );
+ $from = t3lib_utility_Mail::getSystemFrom();
+ /** @var $mail t3lib_mail_Message */
+ $mail = t3lib_div::makeInstance('t3lib_mail_Message');
+ $mail->setTo($email)
+ ->setFrom($from)
+ ->setSubject($subject)
+ ->setBody($email_body);
+ $mail->send();
$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
}
}
Index: typo3/sysext/reports/tasks/class.tx_reports_tasks_systemstatusupdatetask.php
===================================================================
--- typo3/sysext/reports/tasks/class.tx_reports_tasks_systemstatusupdatetask.php (Revision 10226)
+++ typo3/sysext/reports/tasks/class.tx_reports_tasks_systemstatusupdatetask.php (Revision 10227)
@@ -97,8 +97,6 @@
}
}
- $fromEmail = $this->getFromAddress();
-
$subject = sprintf(
$GLOBALS['LANG']->getLL('status_updateTask_email_subject'),
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
@@ -118,66 +116,16 @@
$message .= implode(CRLF, $systemIssues);
$message .= CRLF . CRLF;
+ $from = t3lib_utility_Mail::getSystemFrom();
+
$mail = t3lib_div::makeInstance('t3lib_mail_Message');
- $mail->setFrom(array($fromEmail => $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']));
+ $mail->setFrom($from);
$mail->setTo($this->notificationEmail);
$mail->setSubject($subject);
$mail->setBody($message);
$mail->send();
}
-
- /**
- * Tries to find an email address to use for the From email header.
- *
- * Uses a fall back chain:
- * Install Tool ->
- * no-reply@FirstDomainRecordFound ->
- * no-reply@php_uname('n')
- *
- * @return string email address
- */
- protected function getFromAddress() {
- $email = '';
- $user = 'no-reply';
-
- // default
- $email = $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'];
-
- // find domain record
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- // just get us a domain record we can use
- $domainRecord = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
- 'domainName',
- 'sys_domain',
- 'hidden = 0',
- '',
- 'pid ASC, sorting ASC'
- );
-
- if (!empty($domainRecord['domainName'])) {
- $tempUrl = $domainRecord['domainName'];
-
- if (!t3lib_div::isFirstPartOfStr($tempUrl, 'http')) {
- // shouldn't be the case anyways, but you never know
- // ... there're crazy people out there
- $tempUrl = 'http://' .$tempUrl;
- }
-
- $host = parse_url($tempUrl, PHP_URL_HOST);
- }
-
- $email = $user . '@' . $host;
- }
-
- // uname
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $host = php_uname('n');
- $email = $user . '@' . $host;
- }
-
- return $email;
- }
}
Index: typo3/sysext/cms/tslib/class.tslib_pagegen.php
===================================================================
--- typo3/sysext/cms/tslib/class.tslib_pagegen.php (Revision 10226)
+++ typo3/sysext/cms/tslib/class.tslib_pagegen.php (Revision 10227)
@@ -278,6 +278,7 @@
}
// Include HTML mail library?
if ($GLOBALS['TSFE']->config['config']['incT3Lib_htmlmail']) {
+ $GLOBALS['TSFE']->logDeprecatedTyposcript('config.incT3Lib_htmlmail');
$incFilesArray[] = 't3lib/class.t3lib_htmlmail.php';
}
return $incFilesArray;
Index: typo3/sysext/install/mod/class.tx_install.php
===================================================================
--- typo3/sysext/install/mod/class.tx_install.php (Revision 10226)
+++ typo3/sysext/install/mod/class.tx_install.php (Revision 10227)
@@ -2655,17 +2655,9 @@
case 'get_form':
$out = '
- You can check the mail() function by entering your email
+ You can check the t3lib_mail functionality by entering your email
address here and press the button. You should then
- receive a testmail from test@test.test.
-
- Since almost all mails in TYPO3 are sent using the
- t3lib_htmlmail class, sending with this class can be
- tested by checking the box
- Test t3lib_htmlmail below.
- The return-path of the mail is set to null@' . t3lib_div::getIndpEnv('HTTP_HOST') . '.
- Some mail servers won\'t send the mail if the host of
- the return-path is not resolved correctly.
+ receive a testmail from "typo3installtool@example.org".