# acymailing/11.1.0/back/dynamics/smtp/plugin.php

AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress, version 11.1.0. 170 lines.

- Page: https://pluginprobe.com/plugins/acymailing/11.1.0/code/back/dynamics/smtp/plugin.php
- Raw: https://pluginprobe.com/plugins/acymailing/11.1.0/raw/back/dynamics/smtp/plugin.php
- Modified: 2026-09-24T14:59:06+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/acymailing/11.1.0/code/back/dynamics/smtp/plugin.php#L10-L20`.

```php
<?php

use AcyMailing\Core\AcymPlugin;

class plgAcymSmtp extends AcymPlugin
{
    const SENDING_METHOD_ID = 'smtp';
    const SENDING_METHOD_NAME = 'SMTP';

    public function __construct()
    {
        parent::__construct();
        $this->pluginDescription->name = acym_translation('ACYM_SMTP_SERVICE');
    }

    public function onAcymGetSendingMethods(&$data, $isMailer = false)
    {
        if ($isMailer) return;
        $data['sendingMethods'][self::SENDING_METHOD_ID] = [
            'name' => $this->pluginDescription->name,
            'icon' => 'acymicon-email',
        ];
    }

    public function onAcymGetSendingMethodsHtmlSetting(&$data)
    {
        ?>
		<div class="send_settings grid-x cell large-6 xlarge-5 xxlarge-4 margin-auto" id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings">
			<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
				<label for="smtp_host" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_SERVER')); ?></label>
				<input id="smtp_host" class="cell" type="text" name="config[smtp_host]" value="<?php echo esc_attr($this->config->get('smtp_host')); ?>">
			</div>
			<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
				<label for="smtp_port" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_PORT'));
                    acym_info(['textShownInTooltip' => 'ACYM_SMTP_PORT_DESC']); ?></label>
				<input
						id="smtp_port"
						class="cell medium-6"
						type="number"
						name="config[smtp_port]" value="<?php echo esc_attr($this->config->get('smtp_port')); ?>"
						placeholder="465, 587, 2525, 25">
			</div>
			<div id="available_ports" class="cell acym__sending__methods__one__settings">
                <?php echo esc_html(acym_translation('ACYM_SMTP_AVAILABLE_PORTS')); ?>
                <?php $this->getCopySettingsButton($data, self::SENDING_METHOD_ID, 'wp_mail_smtp'); ?>
			</div>
			<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
				<label for="smtp_secured" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_SECURE'));
                    acym_info(['textShownInTooltip' => 'ACYM_SMTP_SECURE_DESC']); ?></label>
				<div class="cell medium-6">
                    <?php
                    acym_select(
                        [
                            '' => '- - -',
                            'ssl' => 'SSL',
                            'tls' => 'TLS',
                        ],
                        'config[smtp_secured]',
                        $this->config->get('smtp_secured', 'ssl'),
                        [
                            'class' => 'acym__select',
                            'acym-data-infinite' => '',
                        ],
                        '',
                        '',
                        'smtp_secured',
                        false,
                        true
                    );
                    ?>
				</div>
			</div>
			<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
                <?php
                acym_switch([
                    'name' => 'config[smtp_keepalive]',
                    'value' => $this->config->get('smtp_keepalive'),
                    'label' => acym_translation('ACYM_SMTP_ALIVE'),
                    'tip' => ['textShownInTooltip' => 'ACYM_SMTP_ALIVE_DESC'],
                    'labelClass' => 'medium-5 small-9',
                ]);
                ?>
			</div>
			<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
                <?php
                acym_switch([
                    'name' => 'config[smtp_auth]',
                    'value' => $this->config->get('smtp_auth', 1),
                    'label' => acym_translation('ACYM_SMTP_AUTHENTICATION'),
                    'tip' => ['textShownInTooltip' => 'ACYM_SMTP_AUTHENTICATION_DESC'],
                    'labelClass' => 'medium-5 small-9',
                ]);
                ?>
			</div>
			<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
				<label for="smtp_method" class="cell">
                    <?php echo esc_html(acym_translation('ACYM_AUTHENTICATION_METHOD'));
                    acym_info(['textShownInTooltip' => 'ACYM_AUTHENTICATION_METHOD_DESC']); ?>
				</label>
				<div class="cell medium-6">
                    <?php
                    acym_select(
                        [
                            '' => acym_translation('ACYM_AUTOMATIC'),
                            'CRAM-MD5' => 'CRAM-MD5',
                            'LOGIN' => 'LOGIN',
                            'PLAIN' => 'PLAIN',
                        ],
                        'config[smtp_method]',
                        $this->config->get('smtp_method', ''),
                        [
                            'class' => 'acym__select',
                            'acym-data-infinite' => '',
                        ],
                        '',
                        '',
                        'smtp_method',
                        false,
                        true
                    );
                    ?>
				</div>
			</div>
			<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
				<label for="smtp_username" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_USERNAME'));
                    acym_info(['textShownInTooltip' => 'ACYM_SMTP_USERNAME_DESC']); ?></label>
				<input id="smtp_username"
				       class="cell"
				       type="text"
				       name="config[smtp_username]"
				       value="<?php echo esc_attr($this->config->get('smtp_username')); ?>">
			</div>
			<div class="acym__default_auth_sending_params cell">
				<div class="cell grid-x acym_vcenter acym__sending__methods__one__settings" id="oauthParams">
					<label for="smtp_password" class="cell">
                        <?php echo esc_html(acym_translation('ACYM_SMTP_PASSWORD'));
                        acym_info(['textShownInTooltip' => 'ACYM_SMTP_PASSWORD_DESC']); ?>
					</label>
					<input id="smtp_password"
					       class="cell"
					       type="text"
					       name="config[smtp_password]"
					       value="<?php echo esc_attr(str_repeat('*', strlen($this->config->get('smtp_password')))); ?>">
				</div>
			</div>
		</div>
        <?php
    }

    public function onAcymGetSettingsSendingMethodFromPlugin(&$data, $plugin, $method)
    {
        if ($method != self::SENDING_METHOD_ID) return;

        if (ACYM_CMS === 'wordpress' && $plugin === 'wp_mail_smtp') {
            $wpMailSmtpSetting = get_option('wp_mail_smtp', '');
            if (empty($wpMailSmtpSetting) || empty($wpMailSmtpSetting['smtp'])) {
                return;
            }

            $data['smtp_host'] = $wpMailSmtpSetting['smtp']['host'];
            $data['smtp_port'] = $wpMailSmtpSetting['smtp']['port'];
            $data['smtp_secured'] = $wpMailSmtpSetting['smtp']['encryption'];
            $data['smtp_keepalive'] = 1;
            $data['smtp_auth'] = $wpMailSmtpSetting['smtp']['auth'] ? 1 : 0;
            $data['smtp_username'] = $wpMailSmtpSetting['smtp']['user'];
            $data['smtp_password'] = WPMailSMTP\Helpers\Crypto::decrypt($wpMailSmtpSetting['smtp']['pass']);
        }
    }
}

```
