[FEATURE] Retrieve sendmail command from PHP configuration 12/40312/12
authorRomain L <rolel@smile.fr>
Tue, 16 Jun 2015 15:24:05 +0000 (17:24 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Wed, 12 Aug 2015 20:59:43 +0000 (22:59 +0200)
The install tool setting [MAIL][transport_sendmail_command] is now retrieved
from PHP configuration sendmail_path during installation.
As before this settings is only used if you set sendmail as [MAIL][transport]

Resolves: #65791
Releases: master
Change-Id: I06bfdcd4c2c3de3e8c340a15c5a5573cfbe6c678
Reviewed-on: http://review.typo3.org/40312
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Daniel Maier <dani-maier@gmx.de>
Tested-by: Daniel Maier <dani-maier@gmx.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Documentation/Changelog/master/Feature-65791-UsePHPConfiguredSendmailPathIfMAILtransportSendmailIsActive.rst [new file with mode: 0644]
typo3/sysext/install/Classes/Configuration/FeatureManager.php
typo3/sysext/install/Classes/Configuration/Mail/CustomPreset.php [new file with mode: 0644]
typo3/sysext/install/Classes/Configuration/Mail/MailFeature.php [new file with mode: 0644]
typo3/sysext/install/Classes/Configuration/Mail/SendmailPreset.php [new file with mode: 0644]
typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail.html [new file with mode: 0644]
typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Custom.html [new file with mode: 0644]
typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Sendmail.html [new file with mode: 0644]

index ed96d43..32c542d 100644 (file)
@@ -824,7 +824,7 @@ return array(
                'transport_smtp_encrypt' => '',         // String: <em>only with transport=smtp</em>: Connect to the server using the specified transport protocol. Requires openssl library. Usually available: <em>ssl, sslv2, sslv3, tls</em>. Check <a href="http://www.php.net/stream_get_transports" target="_blank">stream_get_transports()</a>.
                'transport_smtp_username' => '',                // String: <em>only with transport=smtp</em>: If your SMTP server requires authentication, enter your username here.
                'transport_smtp_password' => '',                // String: <em>only with transport=smtp</em>: If your SMTP server requires authentication, enter your password here.
-               'transport_sendmail_command' => '/usr/sbin/sendmail -bs',               // String: <em>only with transport=sendmail</em>: The command to call to send a mail locally. The default works on most modern UNIX based mail server (sendmail, postfix, exim)
+               'transport_sendmail_command' => '',             // String: <em>only with transport=sendmail</em>: The command to call to send a mail locally.
                'transport_mbox_file' => '',            // String: <em>only with transport=mbox</em>: The file where to write the mails into. This file will be conforming the mbox format described in RFC 4155. It is a simple text file with a concatenation of all mails. Path must be absolute.
                'defaultMailFromAddress' => '',         // String: This default email address is used when no other "from" address is set for a TYPO3-generated email. You can specify an email address only (ex. info@example.org).
                'defaultMailFromName' => '',            // String: This default name is used when no other "from" name is set for a TYPO3-generated email.
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-65791-UsePHPConfiguredSendmailPathIfMAILtransportSendmailIsActive.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-65791-UsePHPConfiguredSendmailPathIfMAILtransportSendmailIsActive.rst
new file mode 100644 (file)
index 0000000..6c3d82a
--- /dev/null
@@ -0,0 +1,20 @@
+=============================================================================================
+Feature: #65791 - Use PHP configured sendmail path, if [MAIL][transport] = sendmail is active
+=============================================================================================
+
+Description
+===========
+
+The install tool setting [MAIL][transport_sendmail_command] is now retrieved automatically from
+PHP runtime configuration "sendmail_path" during installation (instead of '/usr/sbin/sendmail -bs').
+
+Impact
+======
+
+There are no impacts on current installations.
+
+New installations will have [MAIL][transport_sendmail_command] automatically set during installation
+using "sendmail_path" from PHP runtime configuration. It can still be changed manually.
+
+As this setting is only used if [MAIL][transport] is set to "sendmail", it doesn't have impact on
+other transport schemes.
\ No newline at end of file
index c20273b..46ca898 100644 (file)
@@ -39,6 +39,7 @@ class FeatureManager {
                \TYPO3\CMS\Install\Configuration\Context\ContextFeature::class,
                \TYPO3\CMS\Install\Configuration\Image\ImageFeature::class,
                \TYPO3\CMS\Install\Configuration\ExtbaseObjectCache\ExtbaseObjectCacheFeature::class,
+               \TYPO3\CMS\Install\Configuration\Mail\MailFeature::class,
        );
 
        /**
diff --git a/typo3/sysext/install/Classes/Configuration/Mail/CustomPreset.php b/typo3/sysext/install/Classes/Configuration/Mail/CustomPreset.php
new file mode 100644 (file)
index 0000000..9fd5db4
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+namespace TYPO3\CMS\Install\Configuration\Mail;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Install\Configuration;
+
+/**
+ * Custom preset is a fallback if no other preset fits
+ */
+class CustomPreset extends Configuration\AbstractCustomPreset implements Configuration\CustomPresetInterface {
+
+       /**
+        * @var array Configuration values handled by this preset
+        */
+       protected $configurationValues = array(
+               'MAIL/transport_sendmail_command' => '',
+       );
+}
diff --git a/typo3/sysext/install/Classes/Configuration/Mail/MailFeature.php b/typo3/sysext/install/Classes/Configuration/Mail/MailFeature.php
new file mode 100644 (file)
index 0000000..d33a04f
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+namespace TYPO3\CMS\Install\Configuration\Mail;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Install\Configuration;
+
+/**
+ * Mail feature detects sendmail settings
+ */
+class MailFeature extends Configuration\AbstractFeature implements Configuration\FeatureInterface {
+
+       /**
+        * @var string Name of feature
+        */
+       protected $name = 'Mail';
+
+
+       /**
+        * @var array List of preset classes
+        */
+       protected $presetRegistry = array(
+               SendmailPreset::class,
+               CustomPreset::class,
+       );
+
+}
diff --git a/typo3/sysext/install/Classes/Configuration/Mail/SendmailPreset.php b/typo3/sysext/install/Classes/Configuration/Mail/SendmailPreset.php
new file mode 100644 (file)
index 0000000..66e4e5a
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+namespace TYPO3\CMS\Install\Configuration\Mail;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Install\Configuration;
+
+/**
+ * Sendmail path handling preset
+ */
+class SendmailPreset extends Configuration\AbstractPreset {
+
+       /**
+        * @var string Name of preset
+        */
+       protected $name = 'Sendmail';
+
+       /**
+        * @var int Priority of preset
+        */
+       protected $priority = 50;
+
+       /**
+        * @var array Configuration values handled by this preset
+        */
+       protected $configurationValues = array(
+               'MAIL/transport_sendmail_command' => '',
+       );
+
+       /**
+        * Get configuration values to activate prefix
+        *
+        * @return array Configuration values needed to activate prefix
+        */
+       public function getConfigurationValues() {
+               $configurationValues = $this->configurationValues;
+               $configurationValues['MAIL/transport_sendmail_command'] = $this->getSendmailPath();
+               return $configurationValues;
+       }
+
+       /**
+        * Check if sendmail path if set
+        *
+        * @return bool TRUE if sendmail path if set
+        */
+       public function isAvailable() {
+               return !empty($this->getSendmailPath());
+       }
+
+       /**
+        * Path where executable was found
+        *
+        * @return string|bool Sendmail path or FALSE if not set
+        */
+       public function getSendmailPath() {
+               return ini_get('sendmail_path');
+       }
+
+       /**
+        * Check is preset is currently active on the system
+        *
+        * @return bool TRUE if preset is active
+        */
+       public function isActive() {
+               $this->configurationValues['MAIL/transport_sendmail_command'] = $this->getSendmailPath();
+               return parent::isActive();
+       }
+
+}
diff --git a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail.html b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail.html
new file mode 100644 (file)
index 0000000..effc017
--- /dev/null
@@ -0,0 +1,24 @@
+<div class="toggleGroup">
+       <div class="toggleButton">
+               <h4>Mail handling settings</h4>
+       </div>
+
+       <div class="toggleData" style="display:none">
+               <div class="toggleDataContent">
+                       <p>
+                               Mailer agent in TYPO3 CMS can use the sendmail command line tool
+                               if transport is configured to sendmail. The tool path needs to be
+                               configured correctly depending on the binary that is available
+                               on the system.
+                       </p>
+                       <p>
+                               This module detects the current sendmail path from PHP settings
+                               and allows to set the correct value in TYPO3 settings.
+                       </p>
+
+                       <f:for each="{feature.presetsOrderedByPriority}" as="preset">
+                               <f:render partial="Action/Tool/Configuration/{feature.name}/{preset.name}" arguments="{_all}" />
+                       </f:for>
+               </div>
+       </div>
+</div>
diff --git a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Custom.html b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Custom.html
new file mode 100644 (file)
index 0000000..62f096b
--- /dev/null
@@ -0,0 +1,40 @@
+<div class="typo3-message message-warning">
+       <div class="header-container">
+               <div class="message-header">
+                       <input
+                               type="radio"
+                               class="t3-install-tool-configuration-radio"
+                               id="t3-install-tool-configuration-charset-custom"
+                               name="install[values][{feature.name}][enable]"
+                               value="{preset.name}"
+                               {f:if(condition:'{preset.isActive}', then:'checked="checked"')}
+                       />
+                       <label
+                               for="t3-install-tool-configuration-charset-custom"
+                               class="t3-install-tool-configuration-radio-label"
+                               >
+                               <strong>
+                                       Custom configuration
+                               </strong>
+                               {f:if(condition:'{preset.isActive}', then:' [Active]')}
+                       </label>
+               </div>
+       </div>
+       <div class="message-body>">
+               <p>
+                       Custom sendmail command:
+               </p>
+
+               <f:for each="{preset.configurationValues}" as="configurationValue" key="configurationKey">
+                       <div>
+                               <input
+                                       type="input"
+                                       name="install[values][{feature.name}][{preset.name}][{configurationKey}]"
+                                       value="{configurationValue}"
+                                       />
+                               {configurationKey}
+                       </div>
+               </f:for>
+       </div>
+</div>
+<p></p>
diff --git a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Sendmail.html b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Sendmail.html
new file mode 100644 (file)
index 0000000..1eeaac8
--- /dev/null
@@ -0,0 +1,35 @@
+<div class="typo3-message {f:if(condition:'{preset.isAvailable}', then:'message-ok', else:'message-error')}">
+       <div class="header-container">
+               <div class="message-header">
+                       <input
+                               type="radio"
+                               class="t3-install-tool-configuration-radio"
+                               id="t3-install-tool-configuration-mail-sendmail"
+                               name="install[values][{feature.name}][enable]"
+                               value="{preset.name}"
+                               {f:if(condition:'{preset.isAvailable}', then:'', else:'disabled="disabled"')}
+                               {f:if(condition:'{preset.isActive}', then:'checked="checked"')}
+                       />
+                       <label
+                               for="t3-install-tool-configuration-mail-sendmail"
+                               class="t3-install-tool-configuration-radio-label"
+                       >
+                               <strong>
+                                       Import sendmail command from PHP settings
+                               </strong>
+                               {f:if(condition:'{preset.isActive}', then:' [Active]')}
+                       </label>
+               </div>
+       </div>
+       <div class="message-body>">
+               <f:if condition="{preset.isAvailable}">
+                       <f:then>
+                               If you enable this setting the sendmail command will be set to: <pre>{preset.sendmailPath}</pre>
+                       </f:then>
+                       <f:else>
+                               Sendmail was not found in your PHP settings.
+                       </f:else>
+               </f:if>
+       </div>
+</div>
+<p></p>