PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / trunk
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress vtrunk
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 10.3.0 10.4.0 All 60 releases
acymailing / back / dynamics / smtp / plugin.php

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

172 lines 7.2 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 esc_attr(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 esc_html(acym_translation('ACYM_SMTP_SERVER')); ?></label>
32 <input id="smtp_host" class="cell" type="text" name="config[smtp_host]" value="<?php echo esc_attr($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 esc_html(acym_translation('ACYM_SMTP_PORT'));
36 acym_info(['textShownInTooltip' => 'ACYM_SMTP_PORT_DESC']); ?></label>
37 <input
38 id="smtp_port"
39 class="cell medium-6"
40 type="number"
41 name="config[smtp_port]" value="<?php echo esc_attr($this->config->get('smtp_port')); ?>"
42 placeholder="465, 587, 2525, 25">
43 </div>
44 <div id="available_ports" class="cell acym__sending__methods__one__settings">
45 <?php echo esc_html(acym_translation('ACYM_SMTP_AVAILABLE_PORTS')); ?>
46 <?php $this->getCopySettingsButton($data, self::SENDING_METHOD_ID, 'wp_mail_smtp'); ?>
47 </div>
48 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
49 <label for="smtp_secured" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_SECURE'));
50 acym_info(['textShownInTooltip' => 'ACYM_SMTP_SECURE_DESC']); ?></label>
51 <div class="cell medium-6">
52 <?php
53 acym_select(
54 [
55 '' => '- - -',
56 'ssl' => 'SSL',
57 'tls' => 'TLS',
58 ],
59 'config[smtp_secured]',
60 $this->config->get('smtp_secured', 'ssl'),
61 [
62 'class' => 'acym__select',
63 'acym-data-infinite' => '',
64 ],
65 '',
66 '',
67 'smtp_secured',
68 false,
69 true
70 );
71 ?>
72 </div>
73 </div>
74 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
75 <?php
76 acym_switch([
77 'name' => 'config[smtp_keepalive]',
78 'value' => $this->config->get('smtp_keepalive'),
79 'label' => acym_translation('ACYM_SMTP_ALIVE'),
80 'tip' => ['textShownInTooltip' => 'ACYM_SMTP_ALIVE_DESC'],
81 'labelClass' => 'medium-5 small-9',
82 ]);
83 ?>
84 </div>
85 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
86 <?php
87 acym_switch([
88 'name' => 'config[smtp_auth]',
89 'value' => $this->config->get('smtp_auth', 1),
90 'label' => acym_translation('ACYM_SMTP_AUTHENTICATION'),
91 'tip' => ['textShownInTooltip' => 'ACYM_SMTP_AUTHENTICATION_DESC'],
92 'labelClass' => 'medium-5 small-9',
93 ]);
94 ?>
95 </div>
96 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
97 <label for="smtp_method" class="cell">
98 <?php echo esc_html(acym_translation('ACYM_AUTHENTICATION_METHOD'));
99 acym_info(['textShownInTooltip' => 'ACYM_AUTHENTICATION_METHOD_DESC']); ?>
100 </label>
101 <div class="cell medium-6">
102 <?php
103 acym_select(
104 [
105 '' => acym_translation('ACYM_AUTOMATIC'),
106 'CRAM-MD5' => 'CRAM-MD5',
107 'LOGIN' => 'LOGIN',
108 'PLAIN' => 'PLAIN',
109 ],
110 'config[smtp_method]',
111 $this->config->get('smtp_method', ''),
112 [
113 'class' => 'acym__select',
114 'acym-data-infinite' => '',
115 ],
116 '',
117 '',
118 'smtp_method',
119 false,
120 true
121 );
122 ?>
123 </div>
124 </div>
125 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
126 <label for="smtp_username" class="cell"><?php echo esc_html(acym_translation('ACYM_SMTP_USERNAME'));
127 acym_info(['textShownInTooltip' => 'ACYM_SMTP_USERNAME_DESC']); ?></label>
128 <input id="smtp_username"
129 class="cell"
130 type="text"
131 name="config[smtp_username]"
132 value="<?php echo esc_attr($this->config->get('smtp_username')); ?>">
133 </div>
134 <div class="acym__default_auth_sending_params cell">
135 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings" id="oauthParams">
136 <label for="smtp_password" class="cell">
137 <?php echo esc_html(acym_translation('ACYM_SMTP_PASSWORD'));
138 acym_info(['textShownInTooltip' => 'ACYM_SMTP_PASSWORD_DESC']); ?>
139 </label>
140 <input id="smtp_password"
141 class="cell"
142 type="text"
143 name="config[smtp_password]"
144 value="<?php echo esc_attr(str_repeat('*', strlen($this->config->get('smtp_password')))); ?>">
145 </div>
146 </div>
147 </div>
148 <?php
149 $data['sendingMethodsHtmlSettings'][self::SENDING_METHOD_ID] = ob_get_clean();
150 }
151
152 public function onAcymGetSettingsSendingMethodFromPlugin(&$data, $plugin, $method)
153 {
154 if ($method != self::SENDING_METHOD_ID) return;
155
156 if (ACYM_CMS === 'wordpress' && $plugin === 'wp_mail_smtp') {
157 $wpMailSmtpSetting = get_option('wp_mail_smtp', '');
158 if (empty($wpMailSmtpSetting) || empty($wpMailSmtpSetting['smtp'])) {
159 return;
160 }
161
162 $data['smtp_host'] = $wpMailSmtpSetting['smtp']['host'];
163 $data['smtp_port'] = $wpMailSmtpSetting['smtp']['port'];
164 $data['smtp_secured'] = $wpMailSmtpSetting['smtp']['encryption'];
165 $data['smtp_keepalive'] = 1;
166 $data['smtp_auth'] = $wpMailSmtpSetting['smtp']['auth'] ? 1 : 0;
167 $data['smtp_username'] = $wpMailSmtpSetting['smtp']['user'];
168 $data['smtp_password'] = WPMailSMTP\Helpers\Crypto::decrypt($wpMailSmtpSetting['smtp']['pass']);
169 }
170 }
171 }
172