[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>
Mon, 23 Jul 2012 21:24:04 +0000 (23:24 +0200)
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: Ie1a9600bfe95c94e4250a6888cb29ee0f3b42d11
Fixes: #28684
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/13006
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
t3lib/class.t3lib_formmail.php

index 4c618e8..2a506e2 100644 (file)
@@ -110,6 +110,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']) {
@@ -191,10 +194,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++) {
@@ -234,9 +237,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