[BUGFIX] Sets defaultMailFromAddress as sender for install tool e-mails 26/28926/7
authorTorben Hansen <derhansen@gmail.com>
Fri, 28 Mar 2014 07:49:36 +0000 (08:49 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Wed, 30 Apr 2014 21:10:35 +0000 (23:10 +0200)
This patch sets [MAIL][defaultMailFromAddress] as a sender for successful
and failed login mails for the install tool. If no defaultMailFromAddress
is set, the fallback sender address is set to no-reply@example.com

Resolves: #57401
Releases: 6.2
Change-Id: Ie4e7700fff9858772688486e5efb4a068d2fe7ff
Reviewed-on: https://review.typo3.org/28926
Reviewed-by: Oliver Klee
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Stefan Neufeind
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/install/Classes/Controller/AbstractController.php
typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php
typo3/sysext/install/Resources/Private/Partials/Action/Tool/TestSetup/Mail.html

index 0153728..87ee62e 100644 (file)
@@ -293,7 +293,7 @@ class AbstractController {
                        $mailMessage
                                ->addTo($warningEmailAddress)
                                ->setSubject('Install Tool Login at \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '\'')
-                               ->addFrom('typo3installtool@example.org', 'TYPO3 Install Tool WARNING')
+                               ->addFrom($this->getSenderEmailAddress(), 'TYPO3 Install Tool WARNING')
                                ->setBody('There has been an Install Tool login at TYPO3 site'
                                . ' \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '\''
                                . ' (' . GeneralUtility::getIndpEnv('HTTP_HOST') . ')'
@@ -317,7 +317,7 @@ class AbstractController {
                        $mailMessage
                                ->addTo($warningEmailAddress)
                                ->setSubject('Install Tool Login ATTEMPT at \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '\'')
-                               ->addFrom('typo3installtool@example.org', 'TYPO3 Install Tool WARNING')
+                               ->addFrom($this->getSenderEmailAddress(), 'TYPO3 Install Tool WARNING')
                                ->setBody('There has been an Install Tool login attempt at TYPO3 site'
                                . ' \'' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . '\''
                                . ' (' . GeneralUtility::getIndpEnv('HTTP_HOST') . ')'
@@ -593,4 +593,17 @@ class AbstractController {
                echo $content;
                die;
        }
+
+       /**
+        * Get sender address from configuration
+        * ['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']
+        * If this setting is empty fall back to 'no-reply@example.com'
+        *
+        * @return string Returns an email address
+        */
+       protected function getSenderEmailAddress() {
+               return !empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])
+                       ? $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']
+                       : 'no-reply@example.com';
+       }
 }
index b5e109f..f79deb6 100644 (file)
@@ -97,7 +97,7 @@ class TestSetup extends Action\AbstractAction {
                }
 
                $this->view->assign('actionMessages', $actionMessages);
-
+               $this->view->assign('senderEmailAddress', $this->getSenderEmailAddress());
                $this->view->assign('imageConfiguration', $this->getImageConfiguration());
 
                return $this->view->render();
@@ -122,7 +122,7 @@ class TestSetup extends Action\AbstractAction {
                        $mailMessage = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
                        $mailMessage
                                ->addTo($recipient)
-                               ->addFrom('typo3installtool@example.org', 'TYPO3 CMS install tool')
+                               ->addFrom($this->getSenderEmailAddress(), 'TYPO3 CMS install tool')
                                ->setSubject('Test TYPO3 CMS mail delivery')
                                ->setBody('<html><body>html test content</body></html>')
                                ->addPart('TEST CONTENT')
@@ -135,6 +135,19 @@ class TestSetup extends Action\AbstractAction {
        }
 
        /**
+        * Get sender address from configuration
+        * ['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']
+        * If this setting is empty fall back to 'no-reply@example.com'
+        *
+        * @return string Returns an email address
+        */
+       protected function getSenderEmailAddress() {
+               return !empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])
+                       ? $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']
+                       : 'no-reply@example.com';
+       }
+
+       /**
         * Create true type font test image
         *
         * @return \TYPO3\CMS\Install\Status\StatusInterface
index e2d733e..d6d8004 100644 (file)
@@ -2,7 +2,7 @@
 
 <p>
        You can check the basic mail functionality by entering your email address here and clicking the button.
-       You should then receive a test email from "typo3installtool@example.org".
+       You should then receive a test email from "{senderEmailAddress}".
 </p>
 
 <p>