PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / dynamics / smtp / plugin.php

plugin.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.1.0, at back/dynamics/smtp/plugin.php

170 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use AcyMailing\Core\AcymPlugin;
4
5 class plgAcymSmtp extends AcymPlugin
6 {
7 const SENDING_METHOD_ID = 'smtp';
8 const SENDING_METHOD_NAME = 'SMTP';
9
10 public function __construct()
11 {
12 parent::__construct();
13 $this->pluginDescription->name = acym_translation('ACYM_SMTP_SERVICE');
14 }
15
16 public function onAcymGetSendingMethods(&$data, $isMailer = false)
17 {
18 if ($isMailer) return;
19 $data['sendingMethods'][self::SENDING_METHOD_ID] = [
20 'name' => $this->pluginDescription->name,
21 'icon' => 'acymicon-email',
22 ];
23 }
24
25 public function onAcymGetSendingMethodsHtmlSetting(&$data)
26 {
27 ?>
28 <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">
29 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
30 <label for="smtp_host" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_SERVER')); ?></label>
31 <input id="smtp_host" class="cell" type="text" name="config[smtp_host]" value="<?php echo esc_attr($this->config->get('smtp_host')); ?>">
32 </div>
33 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
34 <label for="smtp_port" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_PORT'));
35 acym_info(['textShownInTooltip' => 'ACYM_SMTP_PORT_DESC']); ?></label>
36 <input
37 id="smtp_port"
38 class="cell medium-6"
39 type="number"
40 name="config[smtp_port]" value="<?php echo esc_attr($this->config->get('smtp_port')); ?>"
41 placeholder="465, 587, 2525, 25">
42 </div>
43 <div id="available_ports" class="cell acym__sending__methods__one__settings">
44 <?php echo esc_html(acym_translation('ACYM_SMTP_AVAILABLE_PORTS')); ?>
45 <?php $this->getCopySettingsButton($data, self::SENDING_METHOD_ID, 'wp_mail_smtp'); ?>
46 </div>
47 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
48 <label for="smtp_secured" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_SECURE'));
49 acym_info(['textShownInTooltip' => 'ACYM_SMTP_SECURE_DESC']); ?></label>
50 <div class="cell medium-6">
51 <?php
52 acym_select(
53 [
54 '' => '- - -',
55 'ssl' => 'SSL',
56 'tls' => 'TLS',
57 ],
58 'config[smtp_secured]',
59 $this->config->get('smtp_secured', 'ssl'),
60 [
61 'class' => 'acym__select',
62 'acym-data-infinite' => '',
63 ],
64 '',
65 '',
66 'smtp_secured',
67 false,
68 true
69 );
70 ?>
71 </div>
72 </div>
73 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
74 <?php
75 acym_switch([
76 'name' => 'config[smtp_keepalive]',
77 'value' => $this->config->get('smtp_keepalive'),
78 'label' => acym_translation('ACYM_SMTP_ALIVE'),
79 'tip' => ['textShownInTooltip' => 'ACYM_SMTP_ALIVE_DESC'],
80 'labelClass' => 'medium-5 small-9',
81 ]);
82 ?>
83 </div>
84 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
85 <?php
86 acym_switch([
87 'name' => 'config[smtp_auth]',
88 'value' => $this->config->get('smtp_auth', 1),
89 'label' => acym_translation('ACYM_SMTP_AUTHENTICATION'),
90 'tip' => ['textShownInTooltip' => 'ACYM_SMTP_AUTHENTICATION_DESC'],
91 'labelClass' => 'medium-5 small-9',
92 ]);
93 ?>
94 </div>
95 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
96 <label for="smtp_method" class="cell">
97 <?php echo esc_html(acym_translation('ACYM_AUTHENTICATION_METHOD'));
98 acym_info(['textShownInTooltip' => 'ACYM_AUTHENTICATION_METHOD_DESC']); ?>
99 </label>
100 <div class="cell medium-6">
101 <?php
102 acym_select(
103 [
104 '' => acym_translation('ACYM_AUTOMATIC'),
105 'CRAM-MD5' => 'CRAM-MD5',
106 'LOGIN' => 'LOGIN',
107 'PLAIN' => 'PLAIN',
108 ],
109 'config[smtp_method]',
110 $this->config->get('smtp_method', ''),
111 [
112 'class' => 'acym__select',
113 'acym-data-infinite' => '',
114 ],
115 '',
116 '',
117 'smtp_method',
118 false,
119 true
120 );
121 ?>
122 </div>
123 </div>
124 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
125 <label for="smtp_username" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_USERNAME'));
126 acym_info(['textShownInTooltip' => 'ACYM_SMTP_USERNAME_DESC']); ?></label>
127 <input id="smtp_username"
128 class="cell"
129 type="text"
130 name="config[smtp_username]"
131 value="<?php echo esc_attr($this->config->get('smtp_username')); ?>">
132 </div>
133 <div class="acym__default_auth_sending_params cell">
134 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings" id="oauthParams">
135 <label for="smtp_password" class="cell">
136 <?php echo esc_html(acym_translation('ACYM_SMTP_PASSWORD'));
137 acym_info(['textShownInTooltip' => 'ACYM_SMTP_PASSWORD_DESC']); ?>
138 </label>
139 <input id="smtp_password"
140 class="cell"
141 type="text"
142 name="config[smtp_password]"
143 value="<?php echo esc_attr(str_repeat('*', strlen($this->config->get('smtp_password')))); ?>">
144 </div>
145 </div>
146 </div>
147 <?php
148 }
149
150 public function onAcymGetSettingsSendingMethodFromPlugin(&$data, $plugin, $method)
151 {
152 if ($method != self::SENDING_METHOD_ID) return;
153
154 if (ACYM_CMS === 'wordpress' && $plugin === 'wp_mail_smtp') {
155 $wpMailSmtpSetting = get_option('wp_mail_smtp', '');
156 if (empty($wpMailSmtpSetting) || empty($wpMailSmtpSetting['smtp'])) {
157 return;
158 }
159
160 $data['smtp_host'] = $wpMailSmtpSetting['smtp']['host'];
161 $data['smtp_port'] = $wpMailSmtpSetting['smtp']['port'];
162 $data['smtp_secured'] = $wpMailSmtpSetting['smtp']['encryption'];
163 $data['smtp_keepalive'] = 1;
164 $data['smtp_auth'] = $wpMailSmtpSetting['smtp']['auth'] ? 1 : 0;
165 $data['smtp_username'] = $wpMailSmtpSetting['smtp']['user'];
166 $data['smtp_password'] = WPMailSMTP\Helpers\Crypto::decrypt($wpMailSmtpSetting['smtp']['pass']);
167 }
168 }
169 }
170