Skip to content
Snippets Groups Projects
Commit 14f822ce authored by Frank Naegler's avatar Frank Naegler Committed by Benni Mack
Browse files

[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: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: default avatarJigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: default avatarJigal van Hemert <jigal.van.hemert@typo3.org>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
parent 0a2bbe9b
Branches
Tags
No related merge requests found
......@@ -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' => '',
];
}
......@@ -31,6 +31,7 @@ class MailFeature extends Configuration\AbstractFeature implements Configuration
*/
protected $presetRegistry = [
SendmailPreset::class,
SmtpPreset::class,
CustomPreset::class,
];
}
......@@ -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;
}
......
<?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;
/**
* SMTP settings handling preset
*/
class SmtpPreset extends Configuration\AbstractPreset
{
/**
* @var string Name of preset
*/
protected $name = 'Smtp';
/**
* @var int Priority of preset
*/
protected $priority = 40;
/**
* @var array Configuration values handled by this preset
*/
protected $configurationValues = [
'MAIL/transport' => '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;
}
}
......@@ -21,10 +21,7 @@
</div>
</div>
<div class="message-body>">
<p>
Custom sendmail command:
</p>
<p>Custom mail settings:</p>
<f:for each="{preset.configurationValues}" as="configurationValue" key="configurationKey">
<div class="form-group">
<label class="col-sm-6 control-label" for="{feature.name}{preset.name}{configurationKey}">{configurationKey}</label>
......
......@@ -24,10 +24,11 @@
<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>
<p>If you enable this setting the sendmail command will be set to:</p>
<p><pre>{preset.sendmailPath}</pre></p>
</f:then>
<f:else>
Sendmail was not found in your PHP settings.
<p>Sendmail was not found in your PHP settings.</p>
</f:else>
</f:if>
</div>
......
<div class="alert {f:if(condition:'{preset.isAvailable}', then:'alert-success', else:'alert-danger')}">
<div class="header-container">
<div class="message-header">
<input
type="radio"
class="t3-install-tool-configuration-radio"
id="t3-install-tool-configuration-mail-smtp"
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-smtp"
class="t3-install-tool-configuration-radio-label"
>
<strong>
SMTP Settings
</strong>
{f:if(condition: preset.isActive, then:' [Active]')}
</label>
</div>
</div>
<div class="message-body>">
<p>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.</p>
</div>
</div>
<p></p>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment