PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.2.2
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.2.2
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 10.2.2, at back/dynamics/smtp/plugin.php

159 lines 6.6 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 ob_start();
28 ?>
29 <div class="send_settings grid-x cell large-6 xlarge-5 xxlarge-4 margin-auto" id="<?php echo self::SENDING_METHOD_ID; ?>_settings">
30 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
31 <label for="smtp_host" class="cell"><?php echo acym_translation('ACYM_SMTP_SERVER'); ?></label>
32 <input id="smtp_host" class="cell" type="text" name="config[smtp_host]" value="<?php echo acym_escape($this->config->get('smtp_host')); ?>">
33 </div>
34 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
35 <label for="smtp_port" class="cell"><?php echo acym_translation('ACYM_SMTP_PORT').acym_info('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 acym_escape($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 <a href="#" id="available_ports_check"><?php echo acym_translation('ACYM_SMTP_AVAILABLE_PORTS'); ?></a>
45 <?php echo $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 acym_translation('ACYM_SMTP_SECURE').acym_info('ACYM_SMTP_SECURE_DESC'); ?></label>
49 <div class="cell medium-6">
50 <?php
51 echo acym_select(
52 [
53 '' => '- - -',
54 'ssl' => 'SSL',
55 'tls' => 'TLS',
56 ],
57 'config[smtp_secured]',
58 $this->config->get('smtp_secured', 'ssl'),
59 [
60 'class' => 'acym__select',
61 'acym-data-infinite' => '',
62 ],
63 '',
64 '',
65 'smtp_secured'
66 );
67 ?>
68 </div>
69 </div>
70 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
71 <?php
72 echo acym_switch(
73 'config[smtp_keepalive]',
74 $this->config->get('smtp_keepalive'),
75 acym_translation('ACYM_SMTP_ALIVE').acym_info('ACYM_SMTP_ALIVE_DESC'),
76 [],
77 'medium-5 small-9'
78 );
79 ?>
80 </div>
81 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
82 <?php
83 echo acym_switch(
84 'config[smtp_auth]',
85 $this->config->get('smtp_auth', 1),
86 acym_translation('ACYM_SMTP_AUTHENTICATION').acym_info('ACYM_SMTP_AUTHENTICATION_DESC'),
87 [],
88 'medium-5 small-9'
89 );
90 ?>
91 </div>
92 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
93 <label for="smtp_method" class="cell"><?php echo acym_translation('ACYM_AUTHENTICATION_METHOD').acym_info('ACYM_AUTHENTICATION_METHOD_DESC'); ?></label>
94 <div class="cell medium-6">
95 <?php
96 echo acym_select(
97 [
98 '' => acym_translation('ACYM_AUTOMATIC'),
99 'CRAM-MD5' => 'CRAM-MD5',
100 'LOGIN' => 'LOGIN',
101 'PLAIN' => 'PLAIN',
102 ],
103 'config[smtp_method]',
104 $this->config->get('smtp_method', ''),
105 [
106 'class' => 'acym__select',
107 'acym-data-infinite' => '',
108 ],
109 '',
110 '',
111 'smtp_method'
112 );
113 ?>
114 </div>
115 </div>
116 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
117 <label for="smtp_username" class="cell"><?php echo acym_translation('ACYM_SMTP_USERNAME').acym_info('ACYM_SMTP_USERNAME_DESC'); ?></label>
118 <input id="smtp_username"
119 class="cell"
120 type="text"
121 name="config[smtp_username]"
122 value="<?php echo acym_escape($this->config->get('smtp_username')); ?>">
123 </div>
124 <div class="acym__default_auth_sending_params cell">
125 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings" id="oauthParams">
126 <label for="smtp_password" class="cell"><?php echo acym_translation('ACYM_SMTP_PASSWORD').acym_info('ACYM_SMTP_PASSWORD_DESC'); ?></label>
127 <input id="smtp_password"
128 class="cell"
129 type="text"
130 name="config[smtp_password]"
131 value="<?php echo str_repeat('*', strlen($this->config->get('smtp_password'))); ?>">
132 </div>
133 </div>
134 </div>
135 <?php
136 $data['sendingMethodsHtmlSettings'][self::SENDING_METHOD_ID] = ob_get_clean();
137 }
138
139 public function onAcymGetSettingsSendingMethodFromPlugin(&$data, $plugin, $method)
140 {
141 if ($method != self::SENDING_METHOD_ID) return;
142
143 if (ACYM_CMS === 'wordpress' && $plugin === 'wp_mail_smtp') {
144 $wpMailSmtpSetting = get_option('wp_mail_smtp', '');
145 if (empty($wpMailSmtpSetting) || empty($wpMailSmtpSetting['smtp'])) {
146 return;
147 }
148
149 $data['smtp_host'] = $wpMailSmtpSetting['smtp']['host'];
150 $data['smtp_port'] = $wpMailSmtpSetting['smtp']['port'];
151 $data['smtp_secured'] = $wpMailSmtpSetting['smtp']['encryption'];
152 $data['smtp_keepalive'] = 1;
153 $data['smtp_auth'] = $wpMailSmtpSetting['smtp']['auth'] ? 1 : 0;
154 $data['smtp_username'] = $wpMailSmtpSetting['smtp']['user'];
155 $data['smtp_password'] = WPMailSMTP\Helpers\Crypto::decrypt($wpMailSmtpSetting['smtp']['pass']);
156 }
157 }
158 }
159