From 14f822ceff61c4d55fb679dbc84b2d128b02e8ae Mon Sep 17 00:00:00 2001 From: Frank Naegler Date: Sun, 26 Mar 2017 15:35:20 +0200 Subject: [PATCH 1/1] [TASK] Add preset for mail SMTP settings in install tool The current mail presets only allow to modify sendmail settings, but it's not possible to configure SMTP settings. Resolves: #80457 Releases: master Change-Id: Ib70351c9048c0ceec2b2a585d43a3ad04c81424e Reviewed-on: https://review.typo3.org/52167 Tested-by: TYPO3com Reviewed-by: Wouter Wolters Reviewed-by: Jigal van Hemert Tested-by: Jigal van Hemert Reviewed-by: Benni Mack Tested-by: Benni Mack --- .../Configuration/Mail/CustomPreset.php | 5 ++ .../Configuration/Mail/MailFeature.php | 1 + .../Configuration/Mail/SendmailPreset.php | 10 ++- .../Classes/Configuration/Mail/SmtpPreset.php | 75 +++++++++++++++++++ .../Tool/Configuration/Mail/Custom.html | 5 +- .../Tool/Configuration/Mail/Sendmail.html | 5 +- .../Action/Tool/Configuration/Mail/Smtp.html | 29 +++++++ 7 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 typo3/sysext/install/Classes/Configuration/Mail/SmtpPreset.php create mode 100644 typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Smtp.html diff --git a/typo3/sysext/install/Classes/Configuration/Mail/CustomPreset.php b/typo3/sysext/install/Classes/Configuration/Mail/CustomPreset.php index 7ae79c69d547..b860dc4d7ff1 100644 --- a/typo3/sysext/install/Classes/Configuration/Mail/CustomPreset.php +++ b/typo3/sysext/install/Classes/Configuration/Mail/CustomPreset.php @@ -25,6 +25,11 @@ class CustomPreset extends Configuration\AbstractCustomPreset implements Configu * @var array Configuration values handled by this preset */ protected $configurationValues = [ + 'MAIL/transport' => '', 'MAIL/transport_sendmail_command' => '', + 'MAIL/transport_smtp_server' => '', + 'MAIL/transport_smtp_encrypt' => '', + 'MAIL/transport_smtp_username' => '', + 'MAIL/transport_smtp_password' => '', ]; } diff --git a/typo3/sysext/install/Classes/Configuration/Mail/MailFeature.php b/typo3/sysext/install/Classes/Configuration/Mail/MailFeature.php index 3a059184048e..b54385bd1698 100644 --- a/typo3/sysext/install/Classes/Configuration/Mail/MailFeature.php +++ b/typo3/sysext/install/Classes/Configuration/Mail/MailFeature.php @@ -31,6 +31,7 @@ class MailFeature extends Configuration\AbstractFeature implements Configuration */ protected $presetRegistry = [ SendmailPreset::class, + SmtpPreset::class, CustomPreset::class, ]; } diff --git a/typo3/sysext/install/Classes/Configuration/Mail/SendmailPreset.php b/typo3/sysext/install/Classes/Configuration/Mail/SendmailPreset.php index d0d0263fe64a..9ffe54094ebd 100644 --- a/typo3/sysext/install/Classes/Configuration/Mail/SendmailPreset.php +++ b/typo3/sysext/install/Classes/Configuration/Mail/SendmailPreset.php @@ -35,8 +35,13 @@ class SendmailPreset extends Configuration\AbstractPreset * @var array Configuration values handled by this preset */ protected $configurationValues = [ + 'MAIL/transport' => 'sendmail', 'MAIL/transport_sendmail_command' => '', - ]; + 'MAIL/transport_smtp_server' => '', + 'MAIL/transport_smtp_encrypt' => '', + 'MAIL/transport_smtp_username' => '', + 'MAIL/transport_smtp_password' => '', + ]; /** * Get configuration values to activate prefix @@ -47,6 +52,9 @@ class SendmailPreset extends Configuration\AbstractPreset { $configurationValues = $this->configurationValues; $configurationValues['MAIL/transport_sendmail_command'] = $this->getSendmailPath(); + if ($this->postValues['Mail']['enable'] === 'Sendmail') { + $configurationValues['MAIL/transport'] = 'sendmail'; + } return $configurationValues; } diff --git a/typo3/sysext/install/Classes/Configuration/Mail/SmtpPreset.php b/typo3/sysext/install/Classes/Configuration/Mail/SmtpPreset.php new file mode 100644 index 000000000000..fb4895b87fc4 --- /dev/null +++ b/typo3/sysext/install/Classes/Configuration/Mail/SmtpPreset.php @@ -0,0 +1,75 @@ + 'smtp', + 'MAIL/transport_sendmail_command' => '', + 'MAIL/transport_smtp_server' => 'localhost:25', + 'MAIL/transport_smtp_encrypt' => '', + 'MAIL/transport_smtp_username' => '', + 'MAIL/transport_smtp_password' => '', + ]; + + /** + * Get configuration values to activate prefix + * + * @return array Configuration values needed to activate prefix + */ + public function getConfigurationValues() + { + $configurationValues = $this->configurationValues; + $keys = array_keys($configurationValues); + foreach ($keys as $key) { + if (!empty($this->postValues['Smtp'][$key])) { + $configurationValues[$key] = $this->postValues['Smtp'][$key]; + } + } + if ($this->postValues['Mail']['enable'] === 'Smtp') { + $configurationValues['MAIL/transport'] = 'smtp'; + } + return $configurationValues; + } + + /** + * Check if sendmail path if set + * + * @return bool TRUE if sendmail path if set + */ + public function isAvailable() + { + return true; + } +} 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 index ce19ff34de9f..b01192983068 100644 --- 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 @@ -21,10 +21,7 @@
-

- Custom sendmail command: -

- +

Custom mail settings:

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 index 8f7fa0290949..b33776c24078 100644 --- 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 @@ -24,10 +24,11 @@
- If you enable this setting the sendmail command will be set to:
{preset.sendmailPath}
+

If you enable this setting the sendmail command will be set to:

+

{preset.sendmailPath}

- Sendmail was not found in your PHP settings. +

Sendmail was not found in your PHP settings.

diff --git a/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Smtp.html b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Smtp.html new file mode 100644 index 000000000000..133bf161c5df --- /dev/null +++ b/typo3/sysext/install/Resources/Private/Partials/Action/Tool/Configuration/Mail/Smtp.html @@ -0,0 +1,29 @@ +
+
+
+ + +
+
+
+

To set up the mailer agent in TYPO3 CMS to use SMTP it's necessary to configure a SMTP server that will take care of the delivery of your emails. + Luckily, the configuration of a SMTP server is generally very easy. This option set some default values for you.

+
+
+

-- 2.20.1