[BUGFIX] Use defaultMailFromName setting in install tool 66/31966/4
authorOliver Hader <oliver@typo3.org>
Mon, 4 Aug 2014 08:50:36 +0000 (10:50 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Wed, 13 Aug 2014 18:27:56 +0000 (20:27 +0200)
The defaultMailFromName setting is not used for sending
the test mails in the install tool.

Resolves: #60758
Releases: master, 6.2
Change-Id: I35e1b887de6b06bb5f301e037d6d412c18ac0b37
Reviewed-on: http://review.typo3.org/31966
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/install/Classes/Controller/AbstractController.php
typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php

index 3e900db..b133b9b 100644 (file)
@@ -281,7 +281,7 @@ class AbstractController {
                        $mailMessage
                                ->addTo($warningEmailAddress)
                                ->setSubject('Install Tool Login at \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '\'')
-                               ->addFrom($this->getSenderEmailAddress(), 'TYPO3 Install Tool WARNING')
+                               ->addFrom($this->getSenderEmailAddress(), $this->getSenderEmailName())
                                ->setBody('There has been an Install Tool login at TYPO3 site'
                                . ' \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '\''
                                . ' (' . GeneralUtility::getIndpEnv('HTTP_HOST') . ')'
@@ -305,7 +305,7 @@ class AbstractController {
                        $mailMessage
                                ->addTo($warningEmailAddress)
                                ->setSubject('Install Tool Login ATTEMPT at \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '\'')
-                               ->addFrom($this->getSenderEmailAddress(), 'TYPO3 Install Tool WARNING')
+                               ->addFrom($this->getSenderEmailAddress(), $this->getSenderEmailName())
                                ->setBody('There has been an Install Tool login attempt at TYPO3 site'
                                . ' \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '\''
                                . ' (' . GeneralUtility::getIndpEnv('HTTP_HOST') . ')'
@@ -594,4 +594,17 @@ class AbstractController {
                        ? $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']
                        : 'no-reply@example.com';
        }
+
+       /**
+        * Gets sender name from configuration
+        * ['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']
+        * If this setting is empty, it falls back to a default string.
+        *
+        * @return string
+        */
+       protected function getSenderEmailName() {
+               return !empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'])
+                       ? $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']
+                       : 'TYPO3 CMS install tool';
+       }
 }
index 316a776..9344716 100644 (file)
@@ -109,10 +109,11 @@ class TestSetup extends Action\AbstractAction {
                        $message->setMessage('Given address is not a valid email address.');
                } else {
                        $recipient = $this->postValues['values']['testEmailRecipient'];
+                       /** @var $mailMessage \TYPO3\CMS\Core\Mail\MailMessage */
                        $mailMessage = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
                        $mailMessage
                                ->addTo($recipient)
-                               ->addFrom($this->getSenderEmailAddress(), 'TYPO3 CMS install tool')
+                               ->addFrom($this->getSenderEmailAddress(), $this->getSenderEmailName())
                                ->setSubject('Test TYPO3 CMS mail delivery')
                                ->setBody('<html><body>html test content</body></html>', 'text/html')
                                ->addPart('TEST CONTENT')
@@ -138,6 +139,19 @@ class TestSetup extends Action\AbstractAction {
        }
 
        /**
+        * Gets sender name from configuration
+        * ['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']
+        * If this setting is empty, it falls back to a default string.
+        *
+        * @return string
+        */
+       protected function getSenderEmailName() {
+               return !empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'])
+                       ? $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']
+                       : 'TYPO3 CMS install tool';
+       }
+
+       /**
         * Create true type font test image
         *
         * @return \TYPO3\CMS\Install\Status\StatusInterface