<optiontype>radioButton</optiontype>
<defaultvalue>encrypt</defaultvalue>
<selectoptions>none:wcf.acp.option.mail_smtp_starttls.none
-may:wcf.acp.option.mail_smtp_starttls.may
encrypt:wcf.acp.option.mail_smtp_starttls.encrypt</selectoptions>
</option>
<option name="mail_smtp_user">
--- /dev/null
+<?php
+
+/**
+ * Migrates away from MAIL_SMTP_STARTTLS = 'may'.
+ *
+ * @author Tim Duesterhus
+ * @copyright 2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package WoltLabSuite\Core
+ */
+
+use wcf\data\option\OptionAction;
+use wcf\util\StringUtil;
+
+if (MAIL_SMTP_STARTTLS != 'may') {
+ return;
+}
+
+$value = 'encrypt';
+if (StringUtil::startsWith(MAIL_SMTP_HOST, 'ssl://')) {
+ $value = 'none';
+} elseif (MAIL_SMTP_PORT == 465) {
+ $value = 'none';
+}
+
+$optionAction = new OptionAction([], 'import', [
+ 'data' => [
+ 'mail_smtp_starttls' => $value,
+ ],
+]);
+$optionAction->executeAction();
* @param int $port port to use
* @param string $username username to use for authentication
* @param string $password corresponding password
- * @param string $starttls one of 'none', 'may' and 'encrypt'
+ * @param string $starttls one of 'none' and 'encrypt'
* @throws \InvalidArgumentException
*/
public function __construct(
switch ($starttls) {
case 'none':
- case 'may':
case 'encrypt':
$this->starttls = $starttls;
break;
default:
throw new \InvalidArgumentException(
- "Invalid STARTTLS preference '" . $starttls . "'. Must be one of 'none', 'may' and 'encrypt'."
+ "Invalid STARTTLS preference '" . $starttls . "'. Must be one of 'none' and 'encrypt'."
);
}
}
\explode("\n", StringUtil::unifyNewlines($this->read([250])[1]))
);
break;
- case 'may':
- if (\in_array('starttls', $this->features)) {
- try {
- $this->starttls();
-
- $this->write('EHLO ' . Email::getHost());
- $this->features = \array_map(
- 'strtolower',
- \explode("\n", StringUtil::unifyNewlines($this->read([250])[1]))
- );
- } catch (\Exception $e) {
- \wcf\functions\exception\logThrowable($e);
- $this->disconnect();
- $this->starttls = 'none';
- $this->connect();
- }
- }
- break;
case 'none':
// nothing to do here
}
<item name="wcf.acp.option.mail_smtp_host"><![CDATA[SMTP-Server]]></item>
<item name="wcf.acp.option.mail_smtp_host.description"><![CDATA[Bei SMTP-Port 465 muss zusätzlich der Präfix <kbd>ssl://</kbd> angegeben werden, etwa <kbd>ssl://mail.example.com</kbd> statt nur <kbd>mail.example.com</kbd>.]]></item>
<item name="wcf.acp.option.mail_smtp_port"><![CDATA[SMTP-Port]]></item>
- <item name="wcf.acp.option.mail_smtp_starttls"><![CDATA[SMTP-Verschlüsselung]]></item>
+ <item name="wcf.acp.option.mail_smtp_starttls"><![CDATA[SMTP-Verschlüsselung (STARTTLS)]]></item>
<item name="wcf.acp.option.mail_smtp_starttls.none"><![CDATA[Deaktivieren]]></item>
- <item name="wcf.acp.option.mail_smtp_starttls.may"><![CDATA[Wenn unterstützt]]></item>
<item name="wcf.acp.option.mail_smtp_starttls.encrypt"><![CDATA[Erzwingen]]></item>
<item name="wcf.acp.option.mail_smtp_starttls.description"><![CDATA[Diese Einstellung steuert die Verwendung von „STARTTLS“. {if LANGUAGE_USE_INFORMAL_VARIANT}Deaktiviere{else}Deaktivieren Sie{/if} diese Option, wenn {if LANGUAGE_USE_INFORMAL_VARIANT}du{else}Sie{/if} E-Mails über SSL (Port 465) {if LANGUAGE_USE_INFORMAL_VARIANT}versendest{else}versenden{/if}!]]></item>
<item name="wcf.acp.option.mail_smtp_user"><![CDATA[SMTP-Benutzer]]></item>
<item name="wcf.acp.devtools.project.apiVersions.description"/>
<item name="wcf.acp.style.globals.pageLogo.description"/>
<item name="wcf.acp.style.globals.pageLogoMobile.description"/>
+ <item name="wcf.acp.option.mail_smtp_starttls.may"/>
</delete>
</language>
<item name="wcf.acp.option.mail_smtp_host"><![CDATA[SMTP Server]]></item>
<item name="wcf.acp.option.mail_smtp_host.description"><![CDATA[The SMTP port 465 requires the host to be prefixed with <kbd>ssl://</kbd>, for example, <kbd>ssl://mail.example.com</kbd> instead of <kbd>mail.example.com</kbd>.]]></item>
<item name="wcf.acp.option.mail_smtp_port"><![CDATA[SMTP Port]]></item>
- <item name="wcf.acp.option.mail_smtp_starttls"><![CDATA[SMTP Encryption]]></item>
+ <item name="wcf.acp.option.mail_smtp_starttls"><![CDATA[SMTP Encryption (STARTTLS)]]></item>
<item name="wcf.acp.option.mail_smtp_starttls.none"><![CDATA[Disabled]]></item>
- <item name="wcf.acp.option.mail_smtp_starttls.may"><![CDATA[If supported]]></item>
<item name="wcf.acp.option.mail_smtp_starttls.encrypt"><![CDATA[Required]]></item>
<item name="wcf.acp.option.mail_smtp_starttls.description"><![CDATA[This option controls the usage of “STARTTLS”. Disable it, if you are using SSL (port 465)!]]></item>
<item name="wcf.acp.option.mail_smtp_user"><![CDATA[SMTP Username]]></item>
<item name="wcf.acp.devtools.project.apiVersions.description"/>
<item name="wcf.acp.style.globals.pageLogo.description"/>
<item name="wcf.acp.style.globals.pageLogoMobile.description"/>
+ <item name="wcf.acp.option.mail_smtp_starttls.may"/>
</delete>
</language>