[!!!][TASK] Remove deprecated mail functionality 07/32907/6
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 21 Sep 2014 20:10:29 +0000 (22:10 +0200)
committerMarkus Klein <klein.t3@reelworx.at>
Tue, 23 Sep 2014 16:34:01 +0000 (18:34 +0200)
Resolves: #61783
Releases: master
Change-Id: Iebe604aca73cee6efc834b1e8c678cd49ce265fc
Reviewed-on: http://review.typo3.org/32907
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Mail/SwiftMailerAdapter.php [deleted file]
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Classes/Utility/MailUtility.php
typo3/sysext/core/Documentation/Changelog/master/Breaking-61783-RemoveDeprecatedMailFunctionality.rst [new file with mode: 0644]
typo3/sysext/core/Migrations/Code/ClassAliasMap.php
typo3/sysext/core/Migrations/Code/LegacyClassesForIde.php
typo3/sysext/core/Tests/Unit/Mail/SwiftMailerAdapterTest.php [deleted file]
typo3/sysext/core/Tests/Unit/Utility/MailUtilityTest.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index d3be52a..a2354ed 100644 (file)
@@ -231,9 +231,6 @@ class Bootstrap {
                        ->initializeL10nLocales()
                        ->convertPageNotFoundHandlingToBoolean()
                        ->registerGlobalDebugFunctions()
-                       // SwiftMailerAdapter is
-                       // @deprecated since 6.1, will be removed two versions later - will be removed together with \TYPO3\CMS\Core\Utility\MailUtility::mail()
-                       ->registerSwiftMailer()
                        ->configureExceptionHandling()
                        ->setMemoryLimit()
                        ->defineTypo3RequestTypes();
@@ -563,18 +560,6 @@ class Bootstrap {
        }
 
        /**
-        * Mail sending via Swift Mailer
-        *
-        * @return \TYPO3\CMS\Core\Core\Bootstrap
-        * @deprecated since 6.1, will be removed two versions later - will be removed together with \TYPO3\CMS\Core\Utility\MailUtility::mail()
-        */
-       protected function registerSwiftMailer() {
-               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'][] =
-                       'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter';
-               return $this;
-       }
-
-       /**
         * Configure and set up exception and error handling
         *
         * @return Bootstrap
diff --git a/typo3/sysext/core/Classes/Mail/SwiftMailerAdapter.php b/typo3/sysext/core/Classes/Mail/SwiftMailerAdapter.php
deleted file mode 100644 (file)
index 8df16eb..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Mail;
-
-/**
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Hook subscriber for using Swift Mailer with \TYPO3\CMS\Core\Utility\MailUtility
- *
- * @author Jigal van Hemert <jigal@xs4all.nl>
- * @deprecated since 6.1, will be removed two versions later - will be removed together with \TYPO3\CMS\Core\Utility\MailUtility::mail()
- */
-class SwiftMailerAdapter implements \TYPO3\CMS\Core\Mail\MailerAdapterInterface {
-
-       /**
-        * @var $mailer \TYPO3\CMS\Core\Mail\Mailer
-        */
-       protected $mailer;
-
-       /**
-        * @var $message Swift_Message
-        */
-       protected $message;
-
-       /**
-        * @var $messageHeaders Swift_Mime_HeaderSet
-        */
-       protected $messageHeaders;
-
-       /**
-        * @var string
-        */
-       protected $boundary = '';
-
-       /**
-        * Constructor
-        *
-        * @return void
-        */
-       public function __construct() {
-               // create mailer object
-               $this->mailer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\Mailer');
-               // create message object
-               $this->message = \Swift_Message::newInstance();
-       }
-
-       /**
-        * Parses parts of the mail message and sends it with the Swift Mailer functions
-        *
-        * @param string $to Email address to send the message to
-        * @param string $subject Subject of mail message
-        * @param string $messageBody Raw body (may be multipart)
-        * @param array $additionalHeaders Additional mail headers
-        * @param array $additionalParameters Extra parameters for the mail() command
-        * @param boolean $fakeSending If set fake sending a mail
-        * @throws \TYPO3\CMS\Core\Exception
-        * @return boolean
-        */
-       public function mail($to, $subject, $messageBody, $additionalHeaders = NULL, $additionalParameters = NULL, $fakeSending = FALSE) {
-               // report success for fake sending
-               if ($fakeSending === TRUE) {
-                       return TRUE;
-               }
-               $this->message->setSubject($subject);
-               // handle recipients
-               $toAddresses = $this->parseAddresses($to);
-               $this->message->setTo($toAddresses);
-               // handle additional headers
-               $headers = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(LF, $additionalHeaders, TRUE);
-               $this->messageHeaders = $this->message->getHeaders();
-               foreach ($headers as $header) {
-                       list($headerName, $headerValue) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $header, FALSE, 2);
-                       $this->setHeader($headerName, $headerValue);
-               }
-               // handle additional parameters (force return path)
-               if (preg_match('/-f\\s*(\\S*?)/', $additionalParameters, $matches)) {
-                       $this->message->setReturnPath($this->unescapeShellArguments($matches[1]));
-               }
-               // handle from:
-               $this->fixSender();
-               // handle message body
-               $this->setBody($messageBody);
-               // send mail
-               $result = $this->mailer->send($this->message);
-               // report success/failure
-               return (bool) $result;
-       }
-
-       /**
-        * Tries to undo the action by escapeshellarg()
-        *
-        * @param string $escapedString String escaped by escapeshellarg()
-        * @return string String with escapeshellarg() action undone as best as possible
-        */
-       protected function unescapeShellArguments($escapedString) {
-               if (TYPO3_OS === 'WIN') {
-                       // on Windows double quotes are used and % signs are replaced by spaces
-                       if (preg_match('/^"([^"]*)"$/', trim($escapedString), $matches)) {
-                               $result = str_replace('\\"', '"', $matches[1]);
-                       }
-               } else {
-                       // on Unix-like systems single quotes are escaped
-                       if (preg_match('/^\'([^' . preg_quote('\'') . ']*)\'$/', trim($escapedString), $matches)) {
-                               $result = str_replace('\\\'', '\'', $matches[1]);
-                       }
-               }
-               return $result;
-       }
-
-       /**
-        * Handles setting and replacing of mail headers
-        *
-        * @param string $headerName Name of header
-        * @param string $headerValue Value of header
-        * @return void
-        */
-       protected function setHeader($headerName, $headerValue) {
-               // check for boundary in headers
-               if (preg_match('/^boundary="(.*)"$/', $headerName, $matches) > 0) {
-                       $this->boundary = $matches[1];
-                       return;
-               }
-
-               // Ignore empty header-values (like from an 'Reply-To:' without an email-address)
-               $headerValue = trim($headerValue);
-               if (empty($headerValue)) {
-                       return;
-               }
-
-               // process other, real headers
-               if ($this->messageHeaders->has($headerName)) {
-                       $header = $this->messageHeaders->get($headerName);
-                       $headerType = $header->getFieldType();
-                       switch ($headerType) {
-                               case \Swift_Mime_Header::TYPE_TEXT:
-                                       $header->setValue($headerValue);
-                                       break;
-                               case \Swift_Mime_Header::TYPE_PARAMETERIZED:
-                                       $header->setValue(rtrim($headerValue, ';'));
-                                       break;
-                               case \Swift_Mime_Header::TYPE_MAILBOX:
-                                       $addressList = $this->parseAddresses($headerValue);
-                                       if (count($addressList) > 0) {
-                                               $header->setNameAddresses($addressList);
-                                       }
-                                       break;
-                               case \Swift_Mime_Header::TYPE_DATE:
-                                       $header->setTimeStamp(strtotime($headerValue));
-                                       break;
-                               case \Swift_Mime_Header::TYPE_ID:
-                                       // remove '<' and '>' from ID headers
-                                       $header->setId(trim($headerValue, '<>'));
-                                       break;
-                               case \Swift_Mime_Header::TYPE_PATH:
-                                       $header->setAddress($headerValue);
-                                       break;
-                       }
-               } else {
-                       switch ($headerName) {
-                               case 'From':
-                               case 'To':
-                               case 'Cc':
-                               case 'Bcc':
-                               case 'Reply-To':
-                               case 'Sender':
-                                       $addressList = $this->parseAddresses($headerValue);
-                                       if (count($addressList) > 0) {
-                                               $this->messageHeaders->addMailboxHeader($headerName, $addressList);
-                                       }
-                                       break;
-                               case 'Date':
-                                       $this->messageHeaders->addDateHeader($headerName, strtotime($headerValue));
-                                       break;
-                               case 'Message-ID':
-                                       // remove '<' and '>' from ID headers
-                                       $this->messageHeaders->addIdHeader($headerName, trim($headerValue, '<>'));
-                               case 'Return-Path':
-                                       $this->messageHeaders->addPathHeader($headerName, $headerValue);
-                                       break;
-                               case 'Content-Type':
-                               case 'Content-Disposition':
-                                       $this->messageHeaders->addParameterizedHeader($headerName, rtrim($headerValue, ';'));
-                                       break;
-                               default:
-                                       $this->messageHeaders->addTextheader($headerName, $headerValue);
-                       }
-               }
-       }
-
-       /**
-        * Sets body of mail message. Handles multi-part and single part messages. Encoded body parts are decoded prior to adding
-        * them to the message object.
-        *
-        * @param string $body Raw body, may be multi-part
-        * @return void
-        */
-       protected function setBody($body) {
-               if ($this->boundary) {
-                       // handle multi-part
-                       $bodyParts = preg_split('/--' . preg_quote($this->boundary, '/') . '(--)?/m', $body, NULL, PREG_SPLIT_NO_EMPTY);
-                       foreach ($bodyParts as $bodyPart) {
-                               // skip empty parts
-                               if (trim($bodyPart) == '') {
-                                       continue;
-                               }
-                               // keep leading white space when exploding the text
-                               $lines = explode(LF, $bodyPart);
-                               // set defaults for this part
-                               $encoding = '';
-                               $charset = 'utf-8';
-                               $contentType = 'text/plain';
-                               // skip intro messages
-                               if (trim($lines[0]) == 'This is a multi-part message in MIME format.') {
-                                       continue;
-                               }
-                               // first line is empty leftover from splitting
-                               array_shift($lines);
-                               while (count($lines) > 0) {
-                                       $line = array_shift($lines);
-                                       if (preg_match('/^content-type:(.*);( charset=(.*))?$/i', $line, $matches)) {
-                                               $contentType = trim($matches[1]);
-                                               if ($matches[2]) {
-                                                       $charset = trim($matches[3]);
-                                               }
-                                       } elseif (preg_match('/^content-transfer-encoding:(.*)$/i', $line, $matches)) {
-                                               $encoding = trim($matches[1]);
-                                       } elseif (strlen(trim($line)) == 0) {
-                                               // empty line before actual content of this part
-                                               break;
-                                       }
-                               }
-                               // use rest of part as body, but reverse encoding first
-                               $bodyPart = $this->decode(implode(LF, $lines), $encoding);
-                               $this->message->addPart($bodyPart, $contentType, $charset);
-                       }
-               } else {
-                       // Handle single body
-                       // The headers have already been set, so use header information
-                       $contentType = $this->message->getContentType();
-                       $charset = $this->message->getCharset();
-                       $encoding = $this->message->getEncoder()->getName();
-                       // reverse encoding and set body
-                       $rawBody = $this->decode($body, $encoding);
-                       $this->message->setBody($rawBody, $contentType, $charset);
-               }
-       }
-
-       /**
-        * Reverts encoding of body text
-        *
-        * @param string $text Body text to be decoded
-        * @param string $encoding Encoding type to be reverted
-        * @return string Decoded message body
-        */
-       protected function decode($text, $encoding) {
-               $result = $text;
-               switch ($encoding) {
-                       case 'quoted-printable':
-                               $result = quoted_printable_decode($text);
-                               break;
-                       case 'base64':
-                               $result = base64_decode($text);
-                               break;
-               }
-               return $result;
-       }
-
-       /**
-        * Parses mailbox headers and turns them into an array.
-        *
-        * Mailbox headers are a comma separated list of 'name <email@example.org' combinations or plain email addresses (or a mix
-        * of these).
-        * The resulting array has key-value pairs where the key is either a number (no display name in the mailbox header) and the
-        * value is the email address, or the key is the email address and the value is the display name.
-        *
-        * @param string $rawAddresses Comma separated list of email addresses (optionally with display name)
-        * @return array Parsed list of addresses.
-        */
-       protected function parseAddresses($rawAddresses = '') {
-               /** @var $addressParser \TYPO3\CMS\Core\Mail\Rfc822AddressesParser */
-               $addressParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\Rfc822AddressesParser', $rawAddresses);
-               $addresses = $addressParser->parseAddressList();
-               $addressList = array();
-               foreach ($addresses as $address) {
-                       if ($address->personal) {
-                               // item with name found ( name <email@example.org> )
-                               $addressList[$address->mailbox . '@' . $address->host] = $address->personal;
-                       } else {
-                               // item without name found ( email@example.org )
-                               $addressList[] = $address->mailbox . '@' . $address->host;
-                       }
-               }
-               return $addressList;
-       }
-
-       /**
-        * Makes sure there is a correct sender set.
-        *
-        * If there is no from header the returnpath will be used. If that also fails a fake address will be used to make sure
-        * Swift Mailer will be able to send the message. Some SMTP server will not accept mail messages without a valid sender.
-        *
-        * @return void
-        */
-       protected function fixSender() {
-               $from = $this->message->getFrom();
-               if (count($from) > 0) {
-                       reset($from);
-                       list($fromAddress, $fromName) = each($from);
-               } else {
-                       $fromAddress = $this->message->getReturnPath();
-                       $fromName = $fromAddress;
-               }
-               if (strlen($fromAddress) == 0) {
-                       $fromAddress = 'no-reply@example.org';
-                       $fromName = 'TYPO3 CMS';
-               }
-               $this->message->setFrom(array($fromAddress => $fromName));
-       }
-
-}
index 4bb847d..bafbe37 100644 (file)
@@ -4667,74 +4667,6 @@ Connection: close
        }
 
        /**
-        * Simple substitute for the PHP function mail() which allows you to specify encoding and character set
-        * The fifth parameter ($encoding) will allow you to specify 'base64' encryption for the output (set $encoding=base64)
-        * Further the output has the charset set to UTF-8 by default.
-        *
-        * @param string $email Email address to send to. (see PHP function mail())
-        * @param string $subject Subject line, non-encoded. (see PHP function mail())
-        * @param string $message Message content, non-encoded. (see PHP function mail())
-        * @param string $headers Headers, separated by LF
-        * @param string $encoding Encoding type: "base64", "quoted-printable", "8bit". Default value is "quoted-printable".
-        * @param string $charset Charset used in encoding-headers (only if $encoding is set to a valid value which produces such a header)
-        * @param boolean $dontEncodeHeader If set, the header content will not be encoded
-        * @return boolean TRUE if mail was accepted for delivery, FALSE otherwise
-        * @deprecated since 6.1, will be removed two versions later - Use \TYPO3\CMS\Core\Mail\Mailer instead
-        */
-       static public function plainMailEncoded($email, $subject, $message, $headers = '', $encoding = 'quoted-printable', $charset = '', $dontEncodeHeader = FALSE) {
-               self::logDeprecatedFunction();
-               if (!$charset) {
-                       $charset = 'utf-8';
-               }
-               $email = self::normalizeMailAddress($email);
-               if (!$dontEncodeHeader) {
-                       // Mail headers must be ASCII, therefore we convert the whole header to either base64 or quoted_printable
-                       $newHeaders = array();
-                       // Split the header in lines and convert each line separately
-                       foreach (explode(LF, $headers) as $line) {
-                               // Field tags must not be encoded
-                               $parts = explode(': ', $line, 2);
-                               if (count($parts) == 2) {
-                                       if (0 == strcasecmp($parts[0], 'from')) {
-                                               $parts[1] = self::normalizeMailAddress($parts[1]);
-                                       }
-                                       $parts[1] = self::encodeHeader($parts[1], $encoding, $charset);
-                                       $newHeaders[] = implode(': ', $parts);
-                               } else {
-                                       // Should never happen - is such a mail header valid? Anyway, just add the unchanged line...
-                                       $newHeaders[] = $line;
-                               }
-                       }
-                       $headers = implode(LF, $newHeaders);
-                       unset($newHeaders);
-                       // Email address must not be encoded, but it could be appended by a name which should be so (e.g. "Kasper Skårhøj <kasperYYYY@typo3.com>")
-                       $email = self::encodeHeader($email, $encoding, $charset);
-                       $subject = self::encodeHeader($subject, $encoding, $charset);
-               }
-               switch ((string) $encoding) {
-                       case 'base64':
-                               $headers = trim($headers) . LF . 'Mime-Version: 1.0' . LF . 'Content-Type: text/plain; charset="' . $charset . '"' . LF . 'Content-Transfer-Encoding: base64';
-                               // Adding LF because I think MS outlook 2002 wants it... may be removed later again.
-                               $message = trim(chunk_split(base64_encode(($message . LF)))) . LF;
-                               break;
-                       case '8bit':
-                               $headers = trim($headers) . LF . 'Mime-Version: 1.0' . LF . 'Content-Type: text/plain; charset=' . $charset . LF . 'Content-Transfer-Encoding: 8bit';
-                               break;
-                       case 'quoted-printable':
-
-                       default:
-                               $headers = trim($headers) . LF . 'Mime-Version: 1.0' . LF . 'Content-Type: text/plain; charset=' . $charset . LF . 'Content-Transfer-Encoding: quoted-printable';
-                               $message = self::quoted_printable($message);
-               }
-               // Headers must be separated by CRLF according to RFC 2822, not just LF.
-               // But many servers (Gmail, for example) behave incorrectly and want only LF.
-               // So we stick to LF in all cases.
-               // Make sure no empty lines are there.
-               $headers = trim(implode(LF, self::trimExplode(LF, $headers, TRUE)));
-               return \TYPO3\CMS\Core\Utility\MailUtility::mail($email, $subject, $message, $headers);
-       }
-
-       /**
         * Implementation of quoted-printable encode.
         * See RFC 1521, section 5.1 Quoted-Printable Content-Transfer-Encoding
         *
index e8819ee..6ae443c 100644 (file)
@@ -22,71 +22,6 @@ namespace TYPO3\CMS\Core\Utility;
 class MailUtility {
 
        /**
-        * 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
-        */
-       static public 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;
-       }
-
-       /**
         * Gets a valid "from" for mail messages (email and name).
         *
         * Ready to be passed to $mail->setFrom()
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-61783-RemoveDeprecatedMailFunctionality.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-61783-RemoveDeprecatedMailFunctionality.rst
new file mode 100644 (file)
index 0000000..5ded70e
--- /dev/null
@@ -0,0 +1,27 @@
+=================================================
+Breaking: #61783 - Removed deprecated mailing API
+=================================================
+
+Description
+===========
+
+The deprecated methods to send email are removed.
+This includes the MailUtility::mail() method, the mail delivery substitution API and the plainMailEncoded() methods.
+
+Impact
+======
+
+Any call to MailUtility::mail() or GeneralUtility::plainMailEncoded() will result in a fatal error.
+The option $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery']
+does not have any effect.
+
+
+Affected installations
+======================
+
+Any installation using an extension still using the deprecated API will fail.
+
+Migration
+=========
+
+Use the \TYPO3\CMS\Core\Mail\Mailer API for sending email.
index 743e83b..8dc7e8a 100644 (file)
@@ -111,7 +111,6 @@ return array(
        't3lib_mail_Message' => 'TYPO3\\CMS\\Core\\Mail\\MailMessage',
        't3lib_mail_MboxTransport' => 'TYPO3\\CMS\\Core\\Mail\\MboxTransport',
        't3lib_mail_Rfc822AddressesParser' => 'TYPO3\\CMS\\Core\\Mail\\Rfc822AddressesParser',
-       't3lib_mail_SwiftMailerAdapter' => 'TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter',
        't3lib_message_AbstractMessage' => 'TYPO3\\CMS\\Core\\Messaging\\AbstractMessage',
        't3lib_message_AbstractStandaloneMessage' => 'TYPO3\\CMS\\Core\\Messaging\\AbstractStandaloneMessage',
        't3lib_message_ErrorpageMessage' => 'TYPO3\\CMS\\Core\\Messaging\\ErrorpageMessage',
index 8960849..5fc7b7d 100644 (file)
@@ -1214,11 +1214,6 @@ class t3lib_mail_Rfc822AddressesParser extends \TYPO3\CMS\Core\Mail\Rfc822Addres
 /**
  * @deprecated since 6.0 will be removed in 7.0
  */
-class t3lib_mail_SwiftMailerAdapter extends \TYPO3\CMS\Core\Mail\SwiftMailerAdapter {}
-
-/**
- * @deprecated since 6.0 will be removed in 7.0
- */
 abstract class t3lib_message_AbstractMessage extends \TYPO3\CMS\Core\Messaging\AbstractMessage {}
 
 /**
diff --git a/typo3/sysext/core/Tests/Unit/Mail/SwiftMailerAdapterTest.php b/typo3/sysext/core/Tests/Unit/Mail/SwiftMailerAdapterTest.php
deleted file mode 100644 (file)
index 6a91fc5..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-namespace TYPO3\CMS\Core\Tests\Unit\Mail;
-
-/**
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-/**
- * Testcase for the \TYPO3\CMS\Core\Mail\SwiftMailerAdapter class.
- *
- * @author Ernesto Baschny <ernst@cron-it.de>
- */
-class SwiftMailerAdapterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
-
-       /**
-        * @var \TYPO3\CMS\Core\Mail\SwiftMailerAdapter
-        */
-       protected $fixture;
-
-       public function setUp() {
-               $this->fixture = $this->getAccessibleMock('\\TYPO3\\CMS\\Core\\Mail\\SwiftMailerAdapter', array('dummy'));
-       }
-
-       //////////////////////////
-       // Tests concerning mail
-       //////////////////////////
-       /**
-        * Data provider for parseAddressesTest
-        *
-        * @return array Data sets
-        */
-       static public function parseAddressesProvider() {
-               return array(
-                       'name &ltemail&gt;' => array('name <email@example.org>', array('email@example.org' => 'name')),
-                       '&lt;email&gt;' => array('<email@example.org>', array('email@example.org')),
-                       'email' => array('email@example.org', array('email@example.org')),
-                       'email1,email2' => array('email1@example.org,email2@example.com', array('email1@example.org', 'email2@example.com')),
-                       'name &ltemail&gt;,email2' => array('name <email1@example.org>,email2@example.com', array('email1@example.org' => 'name', 'email2@example.com')),
-                       '"last, first" &lt;name@example.org&gt;' => array('"last, first" <email@example.org>', array('email@example.org' => '"last, first"')),
-                       'email,name &ltemail&gt;,"last, first" &lt;name@example.org&gt;' => array(
-                               'email1@example.org, name <email2@example.org>, "last, first" <email3@example.org>',
-                               array(
-                                       'email1@example.org',
-                                       'email2@example.org' => 'name',
-                                       'email3@example.org' => '"last, first"'
-                               )
-                       )
-               );
-       }
-
-       /**
-        * @test
-        * @dataProvider parseAddressesProvider
-        */
-       public function parseAddressesTest($source, $addressList) {
-               $this->assertEquals($addressList, $this->fixture->_callRef('parseAddresses', $source));
-       }
-
-}
index ff91493..3330c0d 100644 (file)
@@ -35,54 +35,6 @@ class MailUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                parent::tearDown();
        }
 
-       //////////////////////////
-       // Tests concerning mail
-       //////////////////////////
-       /**
-        * @test
-        */
-       public function mailCallsHook() {
-               $this->doMailCallsHook();
-       }
-
-       /**
-        * @test
-        */
-       public function mailCallsHookWithDefaultMailFrom() {
-               $this->doMailCallsHook('no-reply@localhost', 'TYPO3 Mailer');
-       }
-
-       /**
-        * Method called from tests mailCallsHook() and mailCallsHookWithDefaultMailFrom().
-        */
-       protected function doMailCallsHook($fromAddress = '', $fromName = '') {
-               // Backup configuration
-               $mailConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['MAIL'];
-               $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'] = $fromAddress;
-               $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'] = $fromName;
-               $to = 'john@example.com';
-               $subject = 'Good news everybody!';
-               $messageBody = 'The hooks works!';
-               $additionalHeaders = 'Reply-to: jane@example.com';
-               $additionalParameters = '-f postmaster@example.com';
-               $fakeThis = FALSE;
-               $additionalHeadersExpected = $additionalHeaders;
-               if ($fromAddress !== '' && $fromName !== '') {
-                       $additionalHeadersExpected .= LF . sprintf('From: "%s" <%s>', $fromName, $fromAddress);
-               }
-               $mockMailer = $this->getMock('TYPO3\\CMS\\Core\\Mail\\MailerAdapterInterface', array('mail'));
-               $mockClassName = get_class($mockMailer);
-               \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance($mockClassName, $mockMailer);
-               $mockMailer->expects($this->once())
-                       ->method('mail')
-                       ->with($to, $subject, $messageBody, $additionalHeadersExpected, $additionalParameters, $fakeThis)
-                       ->will($this->returnValue(TRUE));
-               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery'] = array($mockClassName);
-               \TYPO3\CMS\Core\Utility\MailUtility::mail($to, $subject, $messageBody, $additionalHeaders, $additionalParameters);
-               // Restore configuration
-               $GLOBALS['TYPO3_CONF_VARS']['MAIL'] = $mailConfigurationBackup;
-       }
-
        /**
         * @test
         */
index 5141833..833bafa 100644 (file)
@@ -4600,51 +4600,6 @@ class TypoScriptFrontendController {
        }
 
        /**
-        * Substitute function for the PHP mail() function.
-        * It will encode the email with the setting of TS 'config.notification_email_encoding' (base64 or none)
-        * It will also find all links to http:// in the text and substitute with a shorter link using the redirect feature which stores the long link in the database. Depends on configuration in TS 'config.notification_email_urlmode'
-        *
-        * @param string $email recipient email address (or list of)
-        * @param string $subject The subject
-        * @param string $message The message
-        * @param string $headers The headers (string with lines)
-        * @return void
-        * @see \TYPO3\CMS\Core\Utility\GeneralUtility::plainMailEncoded()
-        * @todo Define visibility
-        * @deprecated since 6.1, will be removed two versions later - Use \TYPO3\CMS\Core\Mail\Mailer instead
-        */
-       public function plainMailEncoded($email, $subject, $message, $headers = '') {
-               GeneralUtility::logDeprecatedFunction();
-               // '76', 'all', ''
-               $urlmode = $this->config['config']['notification_email_urlmode'];
-               if ($urlmode) {
-                       $message = GeneralUtility::substUrlsInPlainText($message, $urlmode);
-               }
-               $encoding = $this->config['config']['notification_email_encoding'] ?: '';
-               $charset = $this->renderCharset;
-               $convCharset = FALSE;
-               // do we need to convert mail data?
-               // Respect config.notification_email_charset if it was set
-               if ($this->config['config']['notification_email_charset']) {
-                       $charset = $this->csConvObj->parse_charset($this->config['config']['notification_email_charset']);
-                       if ($charset != $this->renderCharset) {
-                               $convCharset = TRUE;
-                       }
-               } elseif ($this->metaCharset != $this->renderCharset) {
-                       // Use metaCharset for mail if different from renderCharset
-                       $charset = $this->metaCharset;
-                       $convCharset = TRUE;
-               }
-               if ($convCharset) {
-                       $email = $this->csConvObj->conv($email, $this->renderCharset, $charset);
-                       $subject = $this->csConvObj->conv($subject, $this->renderCharset, $charset);
-                       $message = $this->csConvObj->conv($message, $this->renderCharset, $charset);
-                       $headers = $this->csConvObj->conv($headers, $this->renderCharset, $charset);
-               }
-               GeneralUtility::plainMailEncoded($email, $subject, $message, $headers, $encoding, $charset);
-       }
-
-       /**
         * Returns a unique id to be used as a XML ID (in HTML / XHTML mode)
         *
         * @param string $desired The desired id. If already used it is suffixed with a number