Fixed bug #17574: defaultMailFromName not used when defaultMailFromAddress is used...
authorbaschny <baschny@709f56b5-9817-0410-a4d7-c38de5d9e867>
Wed, 23 Feb 2011 14:12:58 +0000 (14:12 +0000)
committerbaschny <baschny@709f56b5-9817-0410-a4d7-c38de5d9e867>
Wed, 23 Feb 2011 14:12:58 +0000 (14:12 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10601 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_formmail.php

index cb60264..187405f 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
 
 2011-02-23  Ernesto Baschny  <ernst@cron-it.de>
 
+       * Fixed bug #17574: defaultMailFromName not used when defaultMailFromAddress is used in mailform (Thanks to Jigal van Hemert)
        * Fixed bug #17314: Swift_RfcComplianceException is always thrown in t3lib_formmail when forceReturnPath=1 is set
 
 2011-02-23  Tolleiv Nietsch  <typo3@tolleiv.de>
index 3ad5675..b371f9d 100644 (file)
@@ -127,11 +127,9 @@ class t3lib_formmail {
                                        ? $valueList['from_name']
                                        : (($valueList['name']) ? $valueList['name'] : '');
                        $this->fromName = $this->sanitizeHeaderString($this->fromName);
-                       $this->fromName = preg_match('/\s|,/', $this->fromName) >= 1 ? '"' . $this->fromName . '"' : $this->fromName;
 
                        $this->replyToName = ($valueList['replyto_name']) ? $valueList['replyto_name'] : $this->fromName;
                        $this->replyToName = $this->sanitizeHeaderString($this->replyToName);
-                       $this->replyToName = preg_match('/\s|,/', $this->replyToName) >= 1 ? '"' . $this->replyToName . '"' : $this->replyToName;
 
                        $this->organisation = ($valueList['organisation']) ? $valueList['organisation'] : '';
                        $this->organisation = $this->sanitizeHeaderString($this->organisation);
@@ -139,14 +137,12 @@ class t3lib_formmail {
                        $this->fromAddress = ($valueList['from_email']) ? $valueList['from_email'] : (
                                ($valueList['email']) ? $valueList['email'] : ''
                        );
-                       $this->fromAddress = t3lib_div::validEmail($this->fromAddress)
-                                       ? $this->fromAddress
-                                       : t3lib_utility_Mail::getSystemFromAddress();
+                       if (!t3lib_div::validEmail($this->fromAddress)) {
+                               $this->fromAddress = t3lib_utility_Mail::getSystemFromAddress();
+                               $this->fromName = t3lib_utility_Mail::getSystemFromName();
+                       }
 
                        $this->replyToAddress = ($valueList['replyto_email']) ? $valueList['replyto_email'] : $this->fromAddress;
-                       $this->replyToAddress = t3lib_div::validEmail($this->replyToAddress)
-                                       ? $this->replyToAddress
-                                       : t3lib_utility_Mail::getSystemFromAddress();
 
                        $this->priority = ($valueList['priority']) ? t3lib_div::intInRange($valueList['priority'], 1, 5) : 3;
 
@@ -226,11 +222,14 @@ class t3lib_formmail {
                                $this->temporaryFiles[] = $theFile;
                        }
 
+                       $from = $this->fromName ? array($this->fromAddress => $this->fromName) : array($this->fromAddress);
                        $this->recipient = $this->parseAddresses($valueList['recipient']);
                        $this->mailMessage->setSubject($this->subject)
-                                       ->setFrom(array($this->fromAddress => $this->fromName))
+                                       ->setFrom($from)
                                        ->setTo($this->recipient)
                                        ->setPriority($this->priority);
+                       $replyTo = $this->replyToName ? array($this->replyToAddress => $this->replyToName) : array($this->replyToAddress);
+                       $this->mailMessage->addReplyTo($replyTo);
                        $this->mailMessage->getHeaders()->addTextHeader('Organization', $this->organisation);
                        if ($valueList['recipient_copy']) {
                                $this->mailMessage->addCc($this->parseAddresses($valueList['recipient_copy']));