[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)
committerGeorg Ringer <mail@ringerge.org>
Fri, 10 Feb 2012 06:00:30 +0000 (07:00 +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: Id04ea398b616b38583bce8517fec8e53bc482144
Fixes: #28684
Releases: 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/8910
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
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