[TASK] Update SwiftMailer to 5.0.1 70/23370/2
authorJigal van Hemert <jigal.van.hemert@typo3.org>
Tue, 27 Aug 2013 16:00:04 +0000 (18:00 +0200)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Tue, 27 Aug 2013 18:21:33 +0000 (20:21 +0200)
Feature wise equal to 4.3.1, but now with MIT license.

Resolves: #51406
Releases: 6.2

Change-Id: Ie0cd306b544c2f56853ca7e16ba6cdd5cdf84a6e
Reviewed-on: https://review.typo3.org/23370
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
28 files changed:
typo3/contrib/swiftmailer/CHANGES
typo3/contrib/swiftmailer/LICENSE
typo3/contrib/swiftmailer/LICENSE.TYPO3-Exception [deleted file]
typo3/contrib/swiftmailer/README
typo3/contrib/swiftmailer/VERSION
typo3/contrib/swiftmailer/classes/Swift.php
typo3/contrib/swiftmailer/classes/Swift/ByteStream/FileByteStream.php
typo3/contrib/swiftmailer/classes/Swift/FileSpool.php
typo3/contrib/swiftmailer/classes/Swift/Mime/ContentEncoder/NativeQpContentEncoder.php
typo3/contrib/swiftmailer/classes/Swift/Mime/ContentEncoder/QpContentEncoder.php
typo3/contrib/swiftmailer/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php [new file with mode: 0644]
typo3/contrib/swiftmailer/classes/Swift/Mime/Headers/AbstractHeader.php
typo3/contrib/swiftmailer/classes/Swift/Mime/SimpleMessage.php
typo3/contrib/swiftmailer/classes/Swift/Mime/SimpleMimeEntity.php
typo3/contrib/swiftmailer/classes/Swift/Plugins/RedirectingPlugin.php
typo3/contrib/swiftmailer/classes/Swift/Preferences.php
typo3/contrib/swiftmailer/classes/Swift/SignedMessage.php
typo3/contrib/swiftmailer/classes/Swift/Signers/DKIMSigner.php
typo3/contrib/swiftmailer/classes/Swift/Signers/DomainKeySigner.php
typo3/contrib/swiftmailer/classes/Swift/Signers/PeclDKIMSigner.php [deleted file]
typo3/contrib/swiftmailer/classes/Swift/Signers/SMimeSigner.php
typo3/contrib/swiftmailer/classes/Swift/SmtpTransport.php
typo3/contrib/swiftmailer/classes/Swift/Transport/AbstractSmtpTransport.php
typo3/contrib/swiftmailer/dependency_maps/cache_deps.php
typo3/contrib/swiftmailer/dependency_maps/message_deps.php
typo3/contrib/swiftmailer/dependency_maps/mime_deps.php
typo3/contrib/swiftmailer/dependency_maps/transport_deps.php
typo3/contrib/swiftmailer/preferences.php

index 7723147..c354474 100755 (executable)
@@ -1,7 +1,27 @@
-Changelog since Version 4.x.x
-=============================
+Changelog
+=========
 
-4.3.0 (2012-01-08)
+5.0.1 (2013-06-17)
+------------------
+
+ * changed the spool to only start the transport when a mail has to be sent
+ * fixed compatibility with PHP 5.2
+ * fixed LICENSE file
+
+5.0.0 (2013-04-30)
+------------------
+
+ * changed the license from LGPL to MIT
+
+4.3.1 (2013-04-11)
+------------------
+
+ * removed usage of the native QP encoder when the charset is not UTF-8
+ * fixed usage of uniqid to avoid collisions
+ * made a performance improvement when tokenizing large headers
+ * fixed usage of the PHP native QP encoder on PHP 5.4.7+
+
+4.3.0 (2013-01-08)
 ------------------
 
  * made the temporary directory configurable via the TMPDIR env variable
index fc8a5de..674bb2a 100755 (executable)
-                  GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
-  This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
-  0. Additional Definitions. 
-
-  As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
-  "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
-  An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
-  A "Combined Work" is a work produced by combining or linking an
-Application with the Library.  The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
-  The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
-  The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
-  1. Exception to Section 3 of the GNU GPL.
-
-  You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
-  2. Conveying Modified Versions.
-
-  If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
-   a) under this License, provided that you make a good faith effort to
-   ensure that, in the event an Application does not supply the
-   function or data, the facility still operates, and performs
-   whatever part of its purpose remains meaningful, or
-
-   b) under the GNU GPL, with none of the additional permissions of
-   this License applicable to that copy.
-
-  3. Object Code Incorporating Material from Library Header Files.
-
-  The object code form of an Application may incorporate material from
-a header file that is part of the Library.  You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
-   a) Give prominent notice with each copy of the object code that the
-   Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the object code with a copy of the GNU GPL and this license
-   document.
-
-  4. Combined Works.
-
-  You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
-   a) Give prominent notice with each copy of the Combined Work that
-   the Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the Combined Work with a copy of the GNU GPL and this license
-   document.
-
-   c) For a Combined Work that displays copyright notices during
-   execution, include the copyright notice for the Library among
-   these notices, as well as a reference directing the user to the
-   copies of the GNU GPL and this license document.
-
-   d) Do one of the following:
-
-       0) Convey the Minimal Corresponding Source under the terms of this
-       License, and the Corresponding Application Code in a form
-       suitable for, and under terms that permit, the user to
-       recombine or relink the Application with a modified version of
-       the Linked Version to produce a modified Combined Work, in the
-       manner specified by section 6 of the GNU GPL for conveying
-       Corresponding Source.
-
-       1) Use a suitable shared library mechanism for linking with the
-       Library.  A suitable mechanism is one that (a) uses at run time
-       a copy of the Library already present on the user's computer
-       system, and (b) will operate properly with a modified version
-       of the Library that is interface-compatible with the Linked
-       Version. 
-
-   e) Provide Installation Information, but only if you would otherwise
-   be required to provide such information under section 6 of the
-   GNU GPL, and only to the extent that such information is
-   necessary to install and execute a modified version of the
-   Combined Work produced by recombining or relinking the
-   Application with a modified version of the Linked Version. (If
-   you use option 4d0, the Installation Information must accompany
-   the Minimal Corresponding Source and Corresponding Application
-   Code. If you use option 4d1, you must provide the Installation
-   Information in the manner specified by section 6 of the GNU GPL
-   for conveying Corresponding Source.)
-
-  5. Combined Libraries.
-
-  You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
-   a) Accompany the combined library with a copy of the same work based
-   on the Library, uncombined with any other library facilities,
-   conveyed under the terms of this License.
-
-   b) Give prominent notice with the combined library that part of it
-   is a work based on the Library, and explaining where to find the
-   accompanying uncombined form of the same work.
-
-  6. Revised Versions of the GNU Lesser General Public License.
-
-  The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-  Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
-  If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
+Copyright (c) 2013 Fabien Potencier
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/typo3/contrib/swiftmailer/LICENSE.TYPO3-Exception b/typo3/contrib/swiftmailer/LICENSE.TYPO3-Exception
deleted file mode 100644 (file)
index c94708c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-Date: Wed, 21 Nov 2012 17:34:10 +0100
-From: Fabien Potencier <fabien.potencier@gmail.com>
-To: Michael Stucki <michael.stucki@typo3.org>
-Subject: Re: Swiftmailer license exception for TYPO3
-
-Hi Michael,
-
-Of course, no problem with providing the exception for any TYPO3 version.
-
-Fabien
-
---
-Fabien Potencier
-Sensio CEO - Symfony lead developer
-sensiolabs.com | symfony.com | fabien.potencier.org
-Tél: +33 1 40 99 80 80
-
-On 11/11/12 1:51 AM, Michael Stucki wrote:
-> Hi Fabien,
->
-> I'm writing you on behalf of the TYPO3 project. You've been in contact
-> with Ernesto Baschny about a year ago regarding as license exception for
-> TYPO3 shipping Swiftmailer. To sum it up: TYPO3 is released under GPLv2
-> and ships with Swiftmailer which is licensed under LGPL.
->
-> The result of your conversation was the following mail which Ernesto
-> added to TYPO3 as you can see here:
-> https://github.com/typo3/TYPO3v4-Core/blob/master/typo3/contrib/swiftmailer/LICENSE.TYPO3v4-Exception
->
-> --- quote ---
->
-> -------- Original-Message --------
-> Subject: Re: LGPLv3 vs GPLv2
->
-> Date: Thu, 08 Sep 2011 21:24:33 +0200
-> From: Fabien POTENCIER <fabien.potencier@gmail.com>
-> To: Ernesto Baschny <ernesto.baschny@typo3.org>
->
-> Hi Ernesto,
->
-> I'm willing to grant the TYPO3 project the right to include Swiftmailer
-> v4 into TYPO3v4, even if it is released under the GPLv2 license.
->
->
-> That being said, I don't know if you need something else from me as I'm
-> not a lawyer either.
->
-> Cheers,
-> Fabien
->
-> --- quote ---
->
-> One year later, we're still working on the same product, however we will
-> soon raise the version number from 4.7 to 6.0. Thus your exception for
-> "TYPO3v4" does not fit anymore.
->
-> I'm writing you because we would like to continue including SwiftMailer
-> even with TYPO3 6.0 and later versions. Thus, would it be ok for you to
-> update the exception slightly and include either just any TYPO3 6.x
-> version or (even better, if possible) any TYPO3 version which is still
-> licensed under GPLv2?
->
-> Thanks a lot in advance. I'm sorry that we have to bug you again with
-> this matter. I'm not a lawyer either, but I think that the license
-> exception we have been using until now was a good and simple solution to
-> make it possible for us to ship with your great library.
->
-> With kind regards
-> Michael Stucki (Core Team Co-Leader)
->
index dfede07..eb5f8bc 100755 (executable)
@@ -2,7 +2,7 @@ Swift Mailer
 ------------
 
 Swift Mailer is a component based mailing solution for PHP 5.
-It is released under the LGPL license.
+It is released under the MIT license.
 
 Homepage:      http://swiftmailer.org
 Documentation: http://swiftmailer.org/docs
index f113ca0..e779eaa 100644 (file)
@@ -21,7 +21,7 @@ abstract class Swift
     public static $inits = array();
 
     /** Swift Mailer Version number generated during dist release process */
-    const VERSION = '4.3.0';
+    const VERSION = '5.0.1';
 
     /**
      * Registers an initializer callable that will be called the first time
index dd666b3..405f8b0 100644 (file)
@@ -46,6 +46,9 @@ class Swift_ByteStream_FileByteStream extends Swift_ByteStream_AbstractFilterabl
      */
     public function __construct($path, $writable = false)
     {
+        if (empty($path)) {
+            throw new Swift_IoException('The path cannot be empty');
+        }
         $this->_path = $path;
         $this->_mode = $writable ? 'w+b' : 'rb';
 
index e458c07..0f01f40 100644 (file)
@@ -141,14 +141,22 @@ class Swift_FileSpool extends Swift_ConfigurableSpool
      */
     public function flushQueue(Swift_Transport $transport, &$failedRecipients = null)
     {
+        $directoryIterator = new DirectoryIterator($this->_path);
+
+        /* Start the transport only if there are queued files to send */
         if (!$transport->isStarted()) {
-            $transport->start();
+            foreach ($directoryIterator as $file) {
+                if (substr($file->getRealPath(), -8) == '.message') {
+                    $transport->start();
+                    break;
+                }
+            }
         }
 
         $failedRecipients = (array) $failedRecipients;
         $count = 0;
         $time = time();
-        foreach (new DirectoryIterator($this->_path) as $file) {
+        foreach ($directoryIterator as $file) {
             $file = $file->getRealPath();
 
             if (substr($file, -8) != '.message') {
index 6a8ea68..f7dac21 100644 (file)
 class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder
 {
     /**
+     * @var null|string
+     */
+    private $charset;
+
+    /**
+     * @param null|string $charset
+     */
+    public function __construct($charset = null)
+    {
+        $this->charset = $charset ? $charset : 'utf-8';
+    }
+
+    /**
      * Notify this observer that the entity's charset has changed.
      *
      * @param string $charset
      */
     public function charsetChanged($charset)
     {
-        if ($charset !== 'utf-8') {
-            throw new RuntimeException(
-                sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $charset));
-        }
+        $this->charset = $charset;
     }
 
     /**
@@ -37,9 +47,16 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con
      * @param Swift_InputByteStream  $is              to write to
      * @param integer                $firstLineOffset
      * @param integer                $maxLineLength   0 indicates the default length for this encoding
+     *
+     * @throws RuntimeException
      */
     public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
     {
+        if ($this->charset !== 'utf-8') {
+            throw new RuntimeException(
+                sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
+        }
+
         $string = '';
 
         while (false !== $bytes = $os->read(8192)) {
@@ -67,9 +84,42 @@ class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_Con
      * @param integer $maxLineLength   0 indicates the default length for this encoding
      *
      * @return string
+     *
+     * @throws RuntimeException
      */
     public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
     {
-        return quoted_printable_encode($string);
+        if ($this->charset !== 'utf-8') {
+            throw new RuntimeException(
+                sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $this->charset));
+        }
+
+        return $this->_standardize(quoted_printable_encode($string));
+    }
+
+    /**
+     * Make sure CRLF is correct and HT/SPACE are in valid places.
+     *
+     * @param string $string
+     *
+     * @return string
+     */
+    protected function _standardize($string)
+    {
+        // transform CR or LF to CRLF
+        $string = preg_replace('~=0D(?!=0A)|(?<!=0D)=0A~', '=0D=0A', $string);
+        // transform =0D=0A to CRLF
+        $string = str_replace(array("\t=0D=0A", " =0D=0A", "=0D=0A"), array("=09\r\n", "=20\r\n", "\r\n"), $string);
+
+        switch ($end = ord(substr($string, -1))) {
+            case 0x09:
+                $string = substr_replace($string, '=09', -1);
+                break;
+            case 0x20:
+                $string = substr_replace($string, '=20', -1);
+                break;
+        }
+
+        return $string;
     }
 }
index 46d356c..059c53d 100644 (file)
@@ -26,7 +26,7 @@ class Swift_Mime_ContentEncoder_QpContentEncoder extends Swift_Encoder_QpEncoder
      * @param Swift_StreamFilter    $filter     if canonicalization should occur
      * @param boolean               $dotEscape  if dot stuffing workaround must be enabled
      */
-    public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape=false)
+    public function __construct(Swift_CharacterStream $charStream, Swift_StreamFilter $filter = null, $dotEscape = false)
     {
         $this->_dotEscape = $dotEscape;
         parent::__construct($charStream, $filter);
diff --git a/typo3/contrib/swiftmailer/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php b/typo3/contrib/swiftmailer/classes/Swift/Mime/ContentEncoder/QpContentEncoderProxy.php
new file mode 100644 (file)
index 0000000..491409a
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+
+/*
+ * This file is part of SwiftMailer.
+ * (c) 2004-2009 Chris Corbyn
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+/**
+ * Proxy for quoted-printable content encoders.
+ *
+ * Switches on the best QP encoder implementation for current charset.
+ *
+ * @package    Swift
+ * @subpackage Mime
+ * @author     Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
+ */
+class Swift_Mime_ContentEncoder_QpContentEncoderProxy implements Swift_Mime_ContentEncoder
+{
+    /**
+     * @var Swift_Mime_ContentEncoder_QpContentEncoder
+     */
+    private $safeEncoder;
+
+    /**
+     * @var Swift_Mime_ContentEncoder_NativeQpContentEncoder
+     */
+    private $nativeEncoder;
+
+    /**
+     * @var null|string
+     */
+    private $charset;
+
+    /**
+     * Constructor.
+     *
+     * @param Swift_Mime_ContentEncoder_QpContentEncoder       $safeEncoder
+     * @param Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder
+     * @param string|null                                      $charset
+     */
+    public function __construct(Swift_Mime_ContentEncoder_QpContentEncoder $safeEncoder, Swift_Mime_ContentEncoder_NativeQpContentEncoder $nativeEncoder, $charset)
+    {
+        $this->safeEncoder = $safeEncoder;
+        $this->nativeEncoder = $nativeEncoder;
+        $this->charset = $charset;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function charsetChanged($charset)
+    {
+        $this->charset = $charset;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function encodeByteStream(Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0, $maxLineLength = 0)
+    {
+        $this->getEncoder()->encodeByteStream($os, $is, $firstLineOffset, $maxLineLength);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getName()
+    {
+        return 'quoted-printable';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function encodeString($string, $firstLineOffset = 0, $maxLineLength = 0)
+    {
+        return $this->getEncoder()->encodeString($string, $firstLineOffset, $maxLineLength);
+    }
+
+    /**
+     * @return Swift_Mime_ContentEncoder
+     */
+    private function getEncoder()
+    {
+        return 'utf-8' === $this->charset ? $this->nativeEncoder : $this->safeEncoder;
+    }
+}
index 716255d..8d6d5f6 100644 (file)
@@ -458,9 +458,11 @@ abstract class Swift_Mime_Headers_AbstractHeader implements Swift_Mime_Header
 
         //Generate atoms; split at all invisible boundaries followed by WSP
         foreach (preg_split('~(?=[ \t])~', $string) as $token) {
-            $tokens = array_merge($tokens, $this->generateTokenLines($token));
+            $newTokens = $this->generateTokenLines($token);
+            foreach ($newTokens as $newToken) {
+                $tokens[] = $newToken;
+            }
         }
-
         return $tokens;
     }
 
index b6a674b..b203644 100644 (file)
@@ -622,10 +622,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
         return 'Message-ID';
     }
 
-    // -- Private methods
-
     /** Turn the body of this message into a child of itself if needed */
-    private function _becomeMimePart()
+    protected function _becomeMimePart()
     {
         $part = new parent($this->getHeaders()->newInstance(), $this->getEncoder(),
             $this->_getCache(), $this->_getGrammar(), $this->_userCharset
@@ -639,6 +637,8 @@ class Swift_Mime_SimpleMessage extends Swift_Mime_MimePart implements Swift_Mime
         return $part;
     }
 
+    // -- Private methods
+    
     /** Get the highest nesting level nested inside this message */
     private function _getTopNestingLevel()
     {
index 4c1df5c..36e10ff 100644 (file)
@@ -82,7 +82,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
      */
     public function __construct(Swift_Mime_HeaderSet $headers, Swift_Mime_ContentEncoder $encoder, Swift_KeyCache $cache, Swift_Mime_Grammar $grammar)
     {
-        $this->_cacheKey = uniqid();
+        $this->_cacheKey = md5(uniqid(getmypid().mt_rand(), true));
         $this->_cache = $cache;
         $this->_headers = $headers;
         $this->_grammar = $grammar;
@@ -415,7 +415,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
     public function getBoundary()
     {
         if (!isset($this->_boundary)) {
-            $this->_boundary = '_=_swift_v4_' . time() . uniqid() . '_=_';
+            $this->_boundary = '_=_swift_v4_' . time() . '_' . md5(getmypid().mt_rand().uniqid('', true)) . '_=_';
         }
 
         return $this->_boundary;
@@ -684,7 +684,7 @@ class Swift_Mime_SimpleMimeEntity implements Swift_Mime_MimeEntity
      */
     protected function getRandomId()
     {
-        $idLeft = time() . '.' . uniqid();
+        $idLeft = md5(getmypid() . '.' . time() . '.' . uniqid(mt_rand(), true));
         $idRight = !empty($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'swift.generated';
         $id = $idLeft . '@' . $idRight;
 
index f4a4c5f..a27db78 100644 (file)
@@ -93,10 +93,19 @@ class Swift_Plugins_RedirectingPlugin implements Swift_Events_SendListener
         $message = $evt->getMessage();
         $headers = $message->getHeaders();
 
-        // save current recipients
-        $headers->addMailboxHeader('X-Swift-To', $message->getTo());
-        $headers->addMailboxHeader('X-Swift-Cc', $message->getCc());
-        $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc());
+        // conditionally save current recipients
+
+        if ($headers->has('to')) {
+            $headers->addMailboxHeader('X-Swift-To', $message->getTo());
+        }
+
+        if ($headers->has('cc')) {
+            $headers->addMailboxHeader('X-Swift-Cc', $message->getCc());
+        }
+
+        if ($headers->has('bcc')) {
+            $headers->addMailboxHeader('X-Swift-Bcc', $message->getBcc());
+        }
 
         // Add hard coded recipient
         $message->addTo($this->_recipient);
index 8df9df8..ded845b 100644 (file)
@@ -94,10 +94,10 @@ class Swift_Preferences
     {
         $dotEscape = !empty($dotEscape);
         Swift_DependencyContainer::getInstance()
-            -> register('mime.qpcontentencoder')
-            -> asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
-            -> withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
-            -> addConstructorValue($dotEscape);
+            ->register('mime.qpcontentencoder')
+            ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
+            ->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
+            ->addConstructorValue($dotEscape);
 
         return $this;
     }
index f96b210..1a073e4 100644 (file)
@@ -124,6 +124,10 @@ class Swift_SignedMessage extends Swift_Message
         $this->savedMessage = array('headers'=> array());
         $this->savedMessage['body'] = $this->getBody();
         $this->savedMessage['children'] = $this->getChildren();
+        if (count($this->savedMessage['children']) > 0 && $this->getBody() != '') {
+            $this->setChildren(array_merge(array($this->_becomeMimePart()), $this->savedMessage['children']));
+            $this->setBody('');
+        }
     }
 
     protected function saveHeaders(array $altered)
index f01acc9..09a2ccd 100644 (file)
@@ -353,11 +353,11 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
      */
     public function setBodySignedLen($len)
     {
-        if ($this->len === true) {
+        if ($len === true) {
             $this->_showLen = true;
             $this->_maxLen = PHP_INT_MAX;
-        } elseif ($this->len === false) {
-            $this->_showLen = false;
+        } elseif ($len === false) {
+            $this->showLen = false;
             $this->_maxLen = PHP_INT_MAX;
         } else {
             $this->_showLen = true;
@@ -657,10 +657,13 @@ class Swift_Signers_DKIMSigner implements Swift_Signers_HeaderSigner
                 $algorithm = 'sha256';
                 break;
         }
+        $pkeyId=openssl_get_privatekey($this->_privateKey);
+        if (!$pkeyId) {
+            throw new Swift_SwiftException('Unable to load DKIM Private Key ['.openssl_error_string().']');
+        }
         if (openssl_sign($this->_headerCanonData, $signature, $this->_privateKey, $algorithm)) {
             return $signature;
         }
-
-        return '';
+        throw new Swift_SwiftException('Unable to sign DKIM Hash ['.openssl_error_string().']');
     }
 }
index 3d4a9ac..f817e45 100644 (file)
@@ -493,17 +493,13 @@ class Swift_Signers_DomainKeySigner implements Swift_Signers_HeaderSigner
     private function _getEncryptedHash()
     {
         $signature = '';
-        $sig2 = '';
-        openssl_sign($this->_canonData, $sig2, $this->_privateKey, 'sha1');
-        var_dump($this->_hash);
-        var_dump($this->_privateKey);
-        if (openssl_private_encrypt($this->_hash, $signature, $this->_privateKey)) {
-            var_dump($this->_canonData, base64_encode($sig2), base64_encode($signature));
-
-            return $sig2;
+        $pkeyId=openssl_get_privatekey($this->_privateKey);
+        if (!$pkeyId) {
+            throw new Swift_SwiftException('Unable to load DomainKey Private Key ['.openssl_error_string().']');
+        }
+        if (openssl_sign($this->_canonData, $signature, $pkeyId, 'sha1')) {
             return $signature;
         }
-
-        return '';
+        throw new Swift_SwiftException('Unable to sign DomainKey Hash  ['.openssl_error_string().']');
     }
 }
diff --git a/typo3/contrib/swiftmailer/classes/Swift/Signers/PeclDKIMSigner.php b/typo3/contrib/swiftmailer/classes/Swift/Signers/PeclDKIMSigner.php
deleted file mode 100644 (file)
index af45fd2..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-
-/*
- * This file is part of SwiftMailer.
- * (c) 2004-2009 Chris Corbyn
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * DKIM Signer used to apply DKIM Signature to a message
- * Takes advantage of pecl extension or fallbacks to php implementation
- *
- * @package    Swift
- * @subpackage Signatures
- * @author     Xavier De Cock <xdecock@gmail.com>
- */
-
-class Swift_Signer_PeclDKIMSigner extends Swift_Signers_DKIMSigner
-{
-    private $_peclLoaded = false;
-
-    private $_dkimHandler = null;
-
-    public function __construct($privateKey, $domainName, $selector)
-    {
-        parent::__construct($privateKey, $domainName, $selector);
-        if (extension_loaded('dkim')) {
-            $this->_peclLoaded = true;
-        }
-    }
-
-    public function addSignature(Swift_Mime_HeaderSet $headers)
-    {
-        if (! $this->_peclLoaded) {
-            return parent::addSignature($headers);
-        } else {
-            dkim_eom($this->_dkimHandler);
-            $headers->addTextHeader('DKIM-Signature: ', dkim_getsighdr($this->_dkimHandler));
-        }
-
-        return $this;
-    }
-
-    public function setHeaders(Swift_Mime_HeaderSet $headers)
-    {
-        if (! $this->_peclLoaded) {
-            return parent::setHeaders($headers);
-        }
-        //dkim_sign(privateKey, selector, domain[, header_canon[, body_canon[, sign_alg[, body_length]]]])
-        $bodyLen = $this->_bodyLen();
-        if (is_bool($bodyLen)) {
-            $bodyLen = - 1;
-        }
-        $hash = ($this->_hashAlgorithm == 'rsa-sha1') ? DKIM_SIGN_RSASHA1 : DKIM_SIGN_RSASHA256;
-        $bodyCanon = ($this->_bodyCanon == 'simple') ? DKIM_CANON_SIMPLE : DKIM_CANON_RELAXED;
-        $headerCanon = ($this->_headerCanon == 'simple') ? DKIM_CANON_SIMPLE : DKIM_CANON_RELAXED;
-        $this->_dkimHandler = dkim_sign($this->_privateKey, $this->_selector, $this->_domainName, $headerCanon, $bodyCanon, $hash, $bodyLen);
-
-        $listHeaders = $headers->listAll();
-        foreach ($listHeaders as $hName) {
-            // Check if we need to ignore Header
-            if (! isset($this->_ignoredHeaders[strtolower($hName)])) {
-                $tmp = $headers->getAll($hName);
-                if ($headers->has($hName)) {
-                    foreach ($tmp as $header) {
-                        if ($header->getFieldBody() != '') {
-                            dkim_header($this->_dkimHandler, $header->toString());
-                            $this->_signedHeaders[] = $header->getFieldName();
-                        }
-                    }
-                }
-            }
-        }
-
-        return $this;
-    }
-
-    public function startBody()
-    {
-        if (! $this->_peclLoaded) {
-            return parent::startBody();
-        }
-        dkim_eoh($this->_dkimHandler);
-
-        return $this;
-    }
-
-    public function endBody()
-    {
-        if (! $this->_peclLoaded) {
-            return parent::endBody();
-        }
-        dkim_eob($this->_dkimHandler);
-
-        return $this;
-    }
-
-    public function reset()
-    {
-        $this->_dkimHandler = null;
-        parent::reset();
-    }
-
-    // Protected
-
-    protected function _canonicalizeBody($string)
-    {
-        if (! $this->_peclLoaded) {
-            return parent::_canonicalizeBody($string);
-        }
-        dkim_body($this->_dkimHandler, $string);
-    }
-}
index 47c0a3d..54a160e 100644 (file)
@@ -79,7 +79,7 @@ class Swift_Signers_SMimeSigner implements Swift_Signers_BodySigner
      */
     public static function newInstance($certificate = null, $privateKey = null)
     {
-        return new static($certificate, $privateKey);
+        return new self($certificate, $privateKey);
     }
 
     /**
index 4fc750a..0ed3100 100644 (file)
  * @package    Swift
  * @subpackage Transport
  * @author     Chris Corbyn
+ * @method Swift_SmtpTransport setUsername(string $username) Set the username to authenticate with.
+ * @method string              getUsername()                 Get the username to authenticate with.
+ * @method Swift_SmtpTransport setPassword(string $password) Set the password to authenticate with.
+ * @method string              getPassword()                 Get the password to authenticate with.
+ * @method Swift_SmtpTransport setAuthMode(string $mode)     Set the auth mode to use to authenticate.
+ * @method string              getAuthMode()                 Get the auth mode to use to authenticate.
  */
 class Swift_SmtpTransport extends Swift_Transport_EsmtpTransport
 {
index 7a0aa7d..eb10d5c 100644 (file)
@@ -385,8 +385,8 @@ abstract class Swift_Transport_AbstractSmtpTransport implements Swift_Transport
             $this->_throwException(
                 new Swift_TransportException(
                     'Expected response code ' . implode('/', $wanted) . ' but got code ' .
-                    '"' . $code . '", with message "' . $response . '"'
-                    )
+                    '"' . $code . '", with message "' . $response . '"',
+                    $code)
                 );
         }
     }
index e49e8b8..6023448 100644 (file)
@@ -1,23 +1,23 @@
 <?php
 
 Swift_DependencyContainer::getInstance()
-    -> register('cache')
-    -> asAliasOf('cache.array')
+    ->register('cache')
+    ->asAliasOf('cache.array')
 
-    -> register('tempdir')
-    -> asValue('/tmp')
+    ->register('tempdir')
+    ->asValue('/tmp')
 
-    -> register('cache.null')
-    -> asSharedInstanceOf('Swift_KeyCache_NullKeyCache')
+    ->register('cache.null')
+    ->asSharedInstanceOf('Swift_KeyCache_NullKeyCache')
 
-    -> register('cache.array')
-    -> asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache')
-    -> withDependencies(array('cache.inputstream'))
+    ->register('cache.array')
+    ->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache')
+    ->withDependencies(array('cache.inputstream'))
 
-    -> register('cache.disk')
-    -> asSharedInstanceOf('Swift_KeyCache_DiskKeyCache')
-    -> withDependencies(array('cache.inputstream', 'tempdir'))
+    ->register('cache.disk')
+    ->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache')
+    ->withDependencies(array('cache.inputstream', 'tempdir'))
 
-    -> register('cache.inputstream')
-    -> asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream')
+    ->register('cache.inputstream')
+    ->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream')
 ;
index 272cb3a..64d69d2 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 
 Swift_DependencyContainer::getInstance()
-    -> register('message.message')
-    -> asNewInstanceOf('Swift_Message')
+    ->register('message.message')
+    ->asNewInstanceOf('Swift_Message')
 
-    -> register('message.mimepart')
-    -> asNewInstanceOf('Swift_MimePart')
+    ->register('message.mimepart')
+    ->asNewInstanceOf('Swift_MimePart')
 ;
index 25cd94d..a13472e 100644 (file)
@@ -3,15 +3,15 @@
 require dirname(__FILE__) . '/../mime_types.php';
 
 Swift_DependencyContainer::getInstance()
-    -> register('properties.charset')
-    -> asValue('utf-8')
+    ->register('properties.charset')
+    ->asValue('utf-8')
 
-    -> register('mime.grammar')
-    -> asSharedInstanceOf('Swift_Mime_Grammar')
+    ->register('mime.grammar')
+    ->asSharedInstanceOf('Swift_Mime_Grammar')
 
-    -> register('mime.message')
-    -> asNewInstanceOf('Swift_Mime_SimpleMessage')
-    -> withDependencies(array(
+    ->register('mime.message')
+    ->asNewInstanceOf('Swift_Mime_SimpleMessage')
+    ->withDependencies(array(
         'mime.headerset',
         'mime.qpcontentencoder',
         'cache',
@@ -19,9 +19,9 @@ Swift_DependencyContainer::getInstance()
         'properties.charset'
     ))
 
-    -> register('mime.part')
-    -> asNewInstanceOf('Swift_Mime_MimePart')
-    -> withDependencies(array(
+    ->register('mime.part')
+    ->asNewInstanceOf('Swift_Mime_MimePart')
+    ->withDependencies(array(
         'mime.headerset',
         'mime.qpcontentencoder',
         'cache',
@@ -29,94 +29,95 @@ Swift_DependencyContainer::getInstance()
         'properties.charset'
     ))
 
-    -> register('mime.attachment')
-    -> asNewInstanceOf('Swift_Mime_Attachment')
-    -> withDependencies(array(
+    ->register('mime.attachment')
+    ->asNewInstanceOf('Swift_Mime_Attachment')
+    ->withDependencies(array(
         'mime.headerset',
         'mime.base64contentencoder',
         'cache',
         'mime.grammar'
     ))
-    -> addConstructorValue($swift_mime_types)
+    ->addConstructorValue($swift_mime_types)
 
-    -> register('mime.embeddedfile')
-    -> asNewInstanceOf('Swift_Mime_EmbeddedFile')
-    -> withDependencies(array(
+    ->register('mime.embeddedfile')
+    ->asNewInstanceOf('Swift_Mime_EmbeddedFile')
+    ->withDependencies(array(
         'mime.headerset',
         'mime.base64contentencoder',
         'cache',
         'mime.grammar'
     ))
-    -> addConstructorValue($swift_mime_types)
+    ->addConstructorValue($swift_mime_types)
 
-    -> register('mime.headerfactory')
-    -> asNewInstanceOf('Swift_Mime_SimpleHeaderFactory')
-    -> withDependencies(array(
+    ->register('mime.headerfactory')
+    ->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory')
+    ->withDependencies(array(
             'mime.qpheaderencoder',
             'mime.rfc2231encoder',
             'mime.grammar',
             'properties.charset'
         ))
 
-    -> register('mime.headerset')
-    -> asNewInstanceOf('Swift_Mime_SimpleHeaderSet')
-    -> withDependencies(array('mime.headerfactory', 'properties.charset'))
+    ->register('mime.headerset')
+    ->asNewInstanceOf('Swift_Mime_SimpleHeaderSet')
+    ->withDependencies(array('mime.headerfactory', 'properties.charset'))
 
-    -> register('mime.qpheaderencoder')
-    -> asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder')
-    -> withDependencies(array('mime.charstream'))
+    ->register('mime.qpheaderencoder')
+    ->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder')
+    ->withDependencies(array('mime.charstream'))
 
-    -> register('mime.base64headerencoder')
-    -> asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder')
-    -> withDependencies(array('mime.charstream'))
+    ->register('mime.base64headerencoder')
+    ->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder')
+    ->withDependencies(array('mime.charstream'))
 
-    -> register('mime.charstream')
-    -> asNewInstanceOf('Swift_CharacterStream_NgCharacterStream')
-    -> withDependencies(array('mime.characterreaderfactory', 'properties.charset'))
+    ->register('mime.charstream')
+    ->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream')
+    ->withDependencies(array('mime.characterreaderfactory', 'properties.charset'))
 
-    -> register('mime.bytecanonicalizer')
-    -> asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter')
-    -> addConstructorValue(array(array(0x0D, 0x0A), array(0x0D), array(0x0A)))
-    -> addConstructorValue(array(array(0x0A), array(0x0A), array(0x0D, 0x0A)))
+    ->register('mime.bytecanonicalizer')
+    ->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter')
+    ->addConstructorValue(array(array(0x0D, 0x0A), array(0x0D), array(0x0A)))
+    ->addConstructorValue(array(array(0x0A), array(0x0A), array(0x0D, 0x0A)))
 
-    -> register('mime.characterreaderfactory')
-    -> asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory')
+    ->register('mime.characterreaderfactory')
+    ->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory')
 
-    -> register('mime.qpcontentencoder')
-    -> asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
-    -> withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
+    ->register('mime.safeqpcontentencoder')
+    ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
+    ->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
 
-    -> register('mime.rawcontentencoder')
-    -> asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder')
+    ->register('mime.rawcontentencoder')
+    ->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder')
 
-    -> register('mime.nativeqpcontentencoder')
-    -> asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder')
+    ->register('mime.nativeqpcontentencoder')
+    ->withDependencies(array('properties.charset'))
+    ->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder')
 
-    -> register('mime.7bitcontentencoder')
-    -> asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')
-    -> addConstructorValue('7bit')
-    -> addConstructorValue(true)
+    ->register('mime.qpcontentencoderproxy')
+    ->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy')
+    ->withDependencies(array('mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset'))
 
-    -> register('mime.8bitcontentencoder')
-    -> asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')
-    -> addConstructorValue('8bit')
-    -> addConstructorValue(true)
+    ->register('mime.7bitcontentencoder')
+    ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')
+    ->addConstructorValue('7bit')
+    ->addConstructorValue(true)
 
-    -> register('mime.base64contentencoder')
-    -> asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder')
+    ->register('mime.8bitcontentencoder')
+    ->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')
+    ->addConstructorValue('8bit')
+    ->addConstructorValue(true)
 
-    -> register('mime.rfc2231encoder')
-    -> asNewInstanceOf('Swift_Encoder_Rfc2231Encoder')
-    -> withDependencies(array('mime.charstream'))
-;
+    ->register('mime.base64contentencoder')
+    ->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder')
+
+    ->register('mime.rfc2231encoder')
+    ->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder')
+    ->withDependencies(array('mime.charstream'))
 
-// As of PHP 5.4.7, the quoted_printable_encode() function behaves correctly.
-// see https://github.com/php/php-src/commit/18bb426587d62f93c54c40bf8535eb8416603629
-if (version_compare(phpversion(), '5.4.7', '>=')) {
-    Swift_DependencyContainer::getInstance()
-        ->register('mime.qpcontentencoder')
-        ->asAliasOf('mime.nativeqpcontentencoder')
-    ;
-}
+    // As of PHP 5.4.7, the quoted_printable_encode() function behaves correctly.
+    // see https://github.com/php/php-src/commit/18bb426587d62f93c54c40bf8535eb8416603629
+    ->register('mime.qpcontentencoder')
+    ->asAliasOf(version_compare(phpversion(), '5.4.7', '>=') ? 'mime.qpcontentencoderproxy' : 'mime.safeqpcontentencoder')
+;
 
 unset($swift_mime_types);
index f969932..f5605a0 100644 (file)
@@ -1,49 +1,49 @@
 <?php
 
 Swift_DependencyContainer::getInstance()
-    -> register('transport.smtp')
-    -> asNewInstanceOf('Swift_Transport_EsmtpTransport')
-    -> withDependencies(array(
+    ->register('transport.smtp')
+    ->asNewInstanceOf('Swift_Transport_EsmtpTransport')
+    ->withDependencies(array(
         'transport.buffer',
         array('transport.authhandler'),
         'transport.eventdispatcher'
     ))
 
-    -> register('transport.sendmail')
-    -> asNewInstanceOf('Swift_Transport_SendmailTransport')
-    -> withDependencies(array(
+    ->register('transport.sendmail')
+    ->asNewInstanceOf('Swift_Transport_SendmailTransport')
+    ->withDependencies(array(
         'transport.buffer',
         'transport.eventdispatcher'
     ))
 
-    -> register('transport.mail')
-    -> asNewInstanceOf('Swift_Transport_MailTransport')
-    -> withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher'))
+    ->register('transport.mail')
+    ->asNewInstanceOf('Swift_Transport_MailTransport')
+    ->withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher'))
 
-    -> register('transport.loadbalanced')
-    -> asNewInstanceOf('Swift_Transport_LoadBalancedTransport')
+    ->register('transport.loadbalanced')
+    ->asNewInstanceOf('Swift_Transport_LoadBalancedTransport')
 
-    -> register('transport.failover')
-    -> asNewInstanceOf('Swift_Transport_FailoverTransport')
+    ->register('transport.failover')
+    ->asNewInstanceOf('Swift_Transport_FailoverTransport')
 
-    -> register('transport.spool')
-    -> asNewInstanceOf('Swift_Transport_SpoolTransport')
-    -> withDependencies(array('transport.eventdispatcher'))
+    ->register('transport.spool')
+    ->asNewInstanceOf('Swift_Transport_SpoolTransport')
+    ->withDependencies(array('transport.eventdispatcher'))
 
-    -> register('transport.null')
-    -> asNewInstanceOf('Swift_Transport_NullTransport')
-    -> withDependencies(array('transport.eventdispatcher'))
+    ->register('transport.null')
+    ->asNewInstanceOf('Swift_Transport_NullTransport')
+    ->withDependencies(array('transport.eventdispatcher'))
 
-    -> register('transport.mailinvoker')
-    -> asSharedInstanceOf('Swift_Transport_SimpleMailInvoker')
+    ->register('transport.mailinvoker')
+    ->asSharedInstanceOf('Swift_Transport_SimpleMailInvoker')
 
-    -> register('transport.buffer')
-    -> asNewInstanceOf('Swift_Transport_StreamBuffer')
-    -> withDependencies(array('transport.replacementfactory'))
+    ->register('transport.buffer')
+    ->asNewInstanceOf('Swift_Transport_StreamBuffer')
+    ->withDependencies(array('transport.replacementfactory'))
 
-    -> register('transport.authhandler')
-    -> asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler')
-    -> withDependencies(array(
+    ->register('transport.authhandler')
+    ->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler')
+    ->withDependencies(array(
         array(
             'transport.crammd5auth',
             'transport.loginauth',
@@ -51,18 +51,18 @@ Swift_DependencyContainer::getInstance()
         )
     ))
 
-    -> register('transport.crammd5auth')
-    -> asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator')
+    ->register('transport.crammd5auth')
+    ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator')
 
-    -> register('transport.loginauth')
-    -> asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator')
+    ->register('transport.loginauth')
+    ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator')
 
-    -> register('transport.plainauth')
-    -> asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator')
+    ->register('transport.plainauth')
+    ->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator')
 
-    -> register('transport.eventdispatcher')
-    -> asNewInstanceOf('Swift_Events_SimpleEventDispatcher')
+    ->register('transport.eventdispatcher')
+    ->asNewInstanceOf('Swift_Events_SimpleEventDispatcher')
 
-    -> register('transport.replacementfactory')
-    -> asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory')
+    ->register('transport.replacementfactory')
+    ->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory')
 ;
index 91b313b..4223943 100644 (file)
@@ -6,8 +6,10 @@
 /*                                                                          */
 /****************************************************************************/
 
+$preferences = Swift_Preferences::getInstance();
+
 // Sets the default charset so that setCharset() is not needed elsewhere
-Swift_Preferences::getInstance()->setCharset('utf-8');
+$preferences->setCharset('utf-8');
 
 // Without these lines the default caching mechanism is "array" but this uses a lot of memory.
 // If possible, use a disk cache to enable attaching large attachments etc.
@@ -17,13 +19,17 @@ Swift_Preferences::getInstance()->setCharset('utf-8');
 // when using open_basedir
 $tmp = getenv('TMPDIR');
 if ($tmp && @is_writable($tmp)) {
-    Swift_Preferences::getInstance()
+    $preferences
         ->setTempDir($tmp)
         ->setCacheType('disk');
 } elseif (function_exists('sys_get_temp_dir') && @is_writable(sys_get_temp_dir())) {
-    Swift_Preferences::getInstance()
+    $preferences
         ->setTempDir(sys_get_temp_dir())
         ->setCacheType('disk');
 }
 
-Swift_Preferences::getInstance()->setQPDotEscape(false);
+// this should only be done when Swiftmailer won't use the native QP content encoder
+// see mime_deps.php
+if (version_compare(phpversion(), '5.4.7', '<')) {
+    $preferences->setQPDotEscape(false);
+}