kiwicommerce/magento2-enhanced-smtp

Config option "NONE" has empty value instead of "none"

Closed this issue · 1 comments

Config option "NONE" has empty value instead of "none"

Preconditions

  1. Magento 2.3.1
  2. PHP 7.2

Steps to reproduce

  1. Open Backend configuration of the module
  2. Select "NONE" for "Protocol" or for "Authentication"
  3. Save Config

Expected result

The value "none" will be saved and used when sending an Email.

Actual result

An empty value is used when sending an Email.
This breaks a few conditions inside "KiwiCommerce\EnhancedSMTP\Email\Transport.php".

Most critically:

    $auth = strtolower($this->config->getConfig(Config::ENHANCED_SMTP_AUTH));
    if ($auth != 'none') {
        $options->setConnectionClass($auth);

        $connectionConfig = [
            'username' => $this->config->getConfig(Config::ENHANCED_SMTP_USERNAME),
            'password' => $this->config->getConfig(Config::ENHANCED_SMTP_PASSWORD)
        ];
    }

Since $auth != 'none' is matched, because an empty value != 'none', the ConnectioClass will be an empty value. This causes a critical error, since the Zend PluginManager tries to load the class ''.

I found, that inside the files
KiwiCommerce\EnhancedSMTP\Model\Config\Source\SMTP\Authentication.php
and
KiwiCommerce\EnhancedSMTP\Model\Config\Source\SMTP\Protocol.php
you return the options:

    $options = [
        [
            'value' => '',
            'label' => __('None')
        ],

....

So either change the conditions searching for a "none" or fix the values provided in the backend configuration ;)

Hi @Hatsunga . Thank you for your report.
The issue has been fixed.

Related commit(s):
d2eac3f