Remove support for MAIL_SMTP_STARTTLS = 'may'
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 12 Jul 2021 14:06:16 +0000 (16:06 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 12 Jul 2021 14:28:50 +0000 (16:28 +0200)
Resolves #4246

com.woltlab.wcf/option.xml
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.5_starttls.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/email/transport/SmtpEmailTransport.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 56815390ce8b4287542ed36b7c7e8b963d1487ed..3a332b9c1f55079cbbbd1203a9156e682a2ce40c 100644 (file)
@@ -897,7 +897,6 @@ debugFolder:wcf.acp.option.mail_send_method.debugFolder</selectoptions>
                                <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">
diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.5_starttls.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.5_starttls.php
new file mode 100644 (file)
index 0000000..6a817b9
--- /dev/null
@@ -0,0 +1,31 @@
+<?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();
index 3f92a50f7573a116df306fe7f2e407babe5c05cb..e40ded158b710aace0afbe8e3ba79d4817ce246e 100644 (file)
@@ -84,7 +84,7 @@ class SmtpEmailTransport implements IStatusReportingEmailTransport
      * @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(
@@ -101,13 +101,12 @@ class SmtpEmailTransport implements IStatusReportingEmailTransport
 
         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'."
                 );
         }
     }
@@ -287,24 +286,6 @@ class SmtpEmailTransport implements IStatusReportingEmailTransport
                     \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
         }
index b355187756a552daab37b65876a5749c95db0d43..5e4a07b2e4052d4c7681a98fe0468d18deff19a2 100644 (file)
@@ -1349,9 +1349,8 @@ ACHTUNG: Die oben genannten Meldungen sind stark gekürzt. Sie können Details z
                <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>
@@ -5558,5 +5557,6 @@ Benachrichtigungen auf <a href="{link isHtmlEmail=true}{/link}">{PAGE_TITLE|lang
        <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>
index 14ee578d11bae84aa36600bc715481b522b55a89..02b33b30847b8efc60b250ae01b250c39b70774a 100644 (file)
@@ -1327,9 +1327,8 @@ ATTENTION: The messages listed above are greatly shortened. You can view details
                <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>
@@ -5559,5 +5558,6 @@ your notifications on <a href="{link isHtmlEmail=true}{/link}">{PAGE_TITLE|langu
        <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>