[BUGFIX] Formmail doesn't always use correct character set
authorJigal van Hemert <jigal@xs4all.nl>
Sat, 19 Nov 2011 08:32:09 +0000 (09:32 +0100)
committerJigal van Hemert <jigal@xs4all.nl>
Tue, 7 Feb 2012 07:39:40 +0000 (08:39 +0100)
To work around a bug in SwitfMailer the character set of a message part
should always be set. When no character set is explicitly defined use
the renderCharset instead.

Change-Id: I712128156ee86e1d2372fef826703fb35a3b1122
Fixes: #28684
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/6744
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Wouter Wolters
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Philipp Gampe
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
t3lib/class.t3lib_formmail.php

index d87f0af..75a869c 100644 (file)
@@ -96,6 +96,9 @@ class t3lib_formmail {
                } elseif ($GLOBALS['TSFE']->metaCharset != $GLOBALS['TSFE']->renderCharset) {
                                // Use metaCharset for mail if different from renderCharset
                        $this->characterSet = $GLOBALS['TSFE']->metaCharset;
+               } else {
+                               // Otherwise use renderCharset as default
+                       $this->characterSet = $GLOBALS['TSFE']->renderCharset;
                }
 
                if ($base64 || $valueList['use_base64']) {
@@ -177,10 +180,10 @@ class t3lib_formmail {
                        $this->plainContent = $plainTextContent;
 
                        if ($valueList['html_enabled']) {
-                               $this->mailMessage->setBody($htmlContent, 'text/html');
-                               $this->mailMessage->addPart($plainTextContent, 'text/plain');
+                               $this->mailMessage->setBody($htmlContent, 'text/html', $this->characterSet);
+                               $this->mailMessage->addPart($plainTextContent, 'text/plain', $this->characterSet);
                        } else {
-                               $this->mailMessage->setBody($plainTextContent, 'text/plain');
+                               $this->mailMessage->setBody($plainTextContent, 'text/plain', $this->characterSet);
                        }
 
                        for ($a = 0; $a < 10; $a++) {
@@ -220,9 +223,8 @@ class t3lib_formmail {
                        if ($valueList['recipient_copy']) {
                                $this->mailMessage->setCc($this->parseAddresses($valueList['recipient_copy']));
                        }
-                       if ($this->characterSet) {
-                               $this->mailMessage->setCharset($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