PluginProbe ʕ •ᴥ•ʔ
Check & Log Email – Easy Email Testing & Mail logging / 2.0.15
Check & Log Email – Easy Email Testing & Mail logging v2.0.15
2.0.15 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 2.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.13.1 2.0.13.2 2.0.14 2.0.2 2.0.3 2.0.4 2.0.5 2.0.5.1 2.0.6 2.0.7 2.0.8 2.0.9 trunk 0.5.7 0.6.0 0.6.1 0.6.2 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.12.1 1.0.13 1.0.13.1 1.0.2 1.0.3
check-email / include / Check_Email_SMTP_Tab.php
check-email / include Last commit date
Core 4 days ago Util 4 days ago Check_Email_Encode_Tab.php 4 days ago Check_Email_Notify_Tab.php 4 days ago Check_Email_SMTP_Tab.php 4 days ago class-check-email-header-parser.php 4 days ago class-check-email-log-autoloader.php 4 days ago class-check-email-newsletter.php 4 days ago deactivate-feedback.php 4 days ago helper-function.php 4 days ago install.php 4 days ago
Check_Email_SMTP_Tab.php
501 lines
1 <?php
2 defined( 'ABSPATH' ) || exit; // Exit if accessed directly
3
4 /**
5 * @class Check_Email_SMTP_Tab
6 * @since 1.0.12
7 */
8 use CheckEmail\Core\Auth;
9 class Check_Email_SMTP_Tab {
10
11 private $smtp_options;
12
13 public function __construct() {
14 $this->setup_vars();
15
16 add_action( 'check_mail_smtp_form', array($this, 'load_smtp_settings'));
17 add_action('admin_init', array($this, 'smtp_form_submission_handler'));
18 add_action('wp_ajax_check_email_remove_outlook', array( $this, 'check_email_remove_outlook' ));
19
20 if(isset($this->smtp_options['enable_smtp'])){
21 add_action( 'phpmailer_init', array( $this,'check_mail_smtp' ) );
22 add_action( 'check_mail_smtp_admin_update', array($this, 'check_credentials'));
23 add_action( 'admin_notices', array( $this, 'retype_credentials_notice' ) );
24 $this->check_credentials();
25 }
26 }
27
28 /**
29 * Get smtp options
30 *
31 * @return void
32 * @since 1.0.12
33 */
34 public function setup_vars(){
35 $this->smtp_options = get_option('check-email-smtp-options', true);
36 if (is_multisite()) {
37 $smtp_options = get_site_option( 'check-email-log-global-smtp');
38 if ( isset($smtp_options['enable_smtp']) && ! empty($smtp_options['enable_smtp'] ) && isset($smtp_options['enable_global']) && ! empty($smtp_options['enable_global'] )) {
39 $this->smtp_options = $smtp_options;
40 }
41 }
42 }
43
44 /**
45 * PHP mailer setup for SMTP
46 *
47 * @return void
48 * @since 1.0.12
49 */
50 public function check_mail_smtp( $phpmailer ) {
51 if( ! is_email($this->smtp_options["smtp_from"] ) || empty( $this->smtp_options["smtp_host"] ) ) {
52 return;
53 }
54
55 $phpmailer->Mailer = "smtp";
56 $phpmailer->From = $this->smtp_options["smtp_from"];
57 $phpmailer->FromName = $this->smtp_options["smtp_from_name"];
58 $phpmailer->Sender = $phpmailer->From;
59 $phpmailer->AddReplyTo($phpmailer->From,$phpmailer->FromName);
60 $phpmailer->Host = $this->smtp_options["smtp_host"];
61 $phpmailer->SMTPSecure = $this->smtp_options["smtp_secure"];
62 $phpmailer->Port = $this->smtp_options["smtp_port"];
63 $phpmailer->SMTPAuth = ($this->smtp_options["smtp_auth"]=="yes") ? TRUE : FALSE;
64
65 if( $phpmailer->SMTPAuth ){
66 $phpmailer->Username = base64_decode( $this->smtp_options["smtp_username"] );
67 $phpmailer->Password = base64_decode( $this->smtp_options["smtp_password"] );
68 }
69 }
70
71 /**
72 * Check for credentials
73 *
74 * @param array $options WP SMTP options
75 *
76 * @return mixed
77 * @since 1.0.12
78 */
79 public function check_credentials( $options = array(), $pass_ajax = false ) {
80
81 if ( ! is_admin() || ( ! $pass_ajax && defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
82 return;
83 }
84
85 $encription = get_option( 'check_email_smtp_status' );
86
87 // Connecting to host can be a resource heavy task, so we only do it if we need to.
88 if ( 'encrypted' === $encription ) {
89 return true;
90 }
91
92 // Connecting to host can be a resource heavy task, so we only do it if we need to.
93 if ( 'not_encrypted' === $encription ) {
94 add_action( 'admin_notices', array( $this, 'retype_credentials_notice' ) );
95
96 return false;
97 }
98
99 if ( empty( $options ) ) {
100 $options = get_option( 'check-email-smtp-options' );
101 if (is_multisite()) {
102 $smtp_options = get_site_option( 'check-email-log-global-smtp');
103 if ( isset($smtp_options['enable_smtp']) && ! empty($smtp_options['enable_smtp'] ) && isset($smtp_options['enable_global']) && ! empty($smtp_options['enable_global'] )) {
104 $options = $smtp_options;
105 }
106 }
107 }
108
109 if ( ! isset( $options['smtp_username'] ) || ! isset( $options['smtp_password'] ) || ! isset( $options['smtp_host'] ) || ! isset( $options['smtp_port'] ) || ! isset( $options['smtp_auth'] ) || ! isset( $options['smtp_secure'] ) || '' === $options['smtp_username'] || '' === $options['smtp_password'] || '' === $options['smtp_host'] || '' === $options['smtp_port'] || '' === $options['smtp_auth'] ) {
110 return false;
111 }
112
113 global $phpmailer;
114
115 // (Re)create it, if it's gone missing.
116 if ( ! ( $phpmailer instanceof PHPMailer\PHPMailer\PHPMailer ) ) {
117
118 // For WP 6.0+ (PHPMailer as namespace)
119 if ( file_exists( ABSPATH . WPINC . '/PHPMailer/PHPMailer.php' ) ) {
120 require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php';
121 require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php';
122 require_once ABSPATH . WPINC . '/PHPMailer/Exception.php';
123 $phpmailer = new PHPMailer\PHPMailer\PHPMailer( true );
124
125 // For WP 5.x (older PHPMailer class files)
126 } elseif ( file_exists( ABSPATH . WPINC . '/class-phpmailer.php' ) ) {
127 require_once ABSPATH . WPINC . '/class-phpmailer.php';
128 require_once ABSPATH . WPINC . '/class-smtp.php';
129 $phpmailer = new PHPMailer( true );
130 }
131 }
132
133 // Set the timeout to 15 seconds, so if it doesn't connect to not let the user in standby.
134 $smtp = $phpmailer->getSMTPInstance();
135 $smtp->Timeout = 15;
136 $smtp->Timelimit = 15;
137 $phpmailer->Timeout = 15;
138 $phpmailer->Timelimit = 15;
139 $phpmailer->Mailer = "smtp";
140 $phpmailer->Host = $options['smtp_host'];
141 $phpmailer->SMTPAuth = 'yes' === $options['smtp_auth']; // Ask it to use authenticate using the Username and Password properties
142 $phpmailer->Port = $options['smtp_port'];
143 $phpmailer->SMTPKeepAlive = false;
144
145 if ( $phpmailer->SMTPAuth ) {
146 $phpmailer->Username = base64_decode($options['smtp_username']);
147 $phpmailer->Password = base64_decode($options['smtp_password']);
148 }
149
150 $phpmailer->SMTPSecure = $options['smtp_secure']; // preferable but optional
151
152 try {
153 if ( $phpmailer->smtpConnect() ) {
154 update_option( 'check_email_smtp_status', 'encrypted' );
155 return true;
156 } else {
157 update_option( 'check_email_smtp_status', 'not_encrypted' );
158 return false;
159 }
160 } catch ( Exception $e ) {
161 update_option( 'check_email_smtp_status', 'not_encrypted' );
162 return false;
163 }
164 }
165
166 /**
167 * Render SMTP form
168 *
169 * @return void
170 * @since 1.0.12
171 */
172 public function load_smtp_settings(){
173 $check_email = wpchill_check_email();
174 $plugin_dir_url = plugin_dir_url( $check_email->get_plugin_file() );
175 $enable_smtp = isset($this->smtp_options['enable_smtp'])?$this->smtp_options['enable_smtp']:'';
176 $mailer = isset($this->smtp_options['mailer'])?$this->smtp_options['mailer']:'smtp';
177
178 $auth = new Auth( 'outlook' );
179 if ( $mailer == 'outlook' ) {
180 $this->smtp_options = $auth->get_mailer_option();
181 }
182 if (is_multisite()) {
183 $smtp_options = get_site_option( 'check-email-log-global-smtp');
184 if ( isset($smtp_options['enable_global']) && ! empty($smtp_options['enable_global'] ) ) {
185 ?>
186 <div class="notice notice-error is-dismissible">
187 <h3><?php esc_html_e( 'You are using global smtp configuration for multisite', 'check-email' ); ?></h3>
188 <p><?php esc_html_e( 'If you want separate smtp configuration for each site, you need to uncheck setting Control from netework admin.', 'check-email' ); ?></p>
189 </div>
190 <?php
191 exit;
192 }
193 }
194 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
195 if (isset( $_GET['error'] ) ) {
196 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
197 $error = sanitize_text_field( wp_unslash( $_GET['error'] ) );
198 ?> <div class="notice notice-error is-dismissible">
199 <h3><?php esc_html_e( 'Its an error to linking with microsoft 365 / outlook', 'check-email' ); ?></h3>
200 <p><?php echo esc_html( $error ); ?></p>
201 </div>
202 <?php
203 }
204 ?>
205
206 <form action="" method="post" >
207 <div id="check-mail-smtp-wrapper">
208 <table class="form-table" role="presentation">
209 <thead>
210 <tr class="check_email_enable_smtp" >
211 <th scope="row"><label for="check-email-enable-smtp" class="check-email-opt-labels"><?php esc_html_e( 'SMTP', 'check-email' ); ?></label></th>
212 <td>
213 <input id="check-email-enable-smtp" type="checkbox" name="check-email-smtp-options[enable_smtp]" <?php echo $enable_smtp == 'on' ? "checked" : ''; ?>>
214 <label for="check-email-enable-smtp" class="check-email-opt-labels"><?php esc_html_e('Configure your own SMTP instead of the PHP mail()','check-email'); ?></label>
215 </td>
216 </tr>
217 <tr class="check_email_mailer check_email_all_smtp" style="<?php echo $enable_smtp != 'on' ? "display: none" : ''; ?>">
218 <th scope="row"><label for="check-email-mailer" class="check-email-opt-labels"><?php esc_html_e( 'Mailer', 'check-email' ); ?></label></th>
219 <td>
220 <div class="ce_radio-container">
221 <label class="ce_radio-label <?php echo $mailer == 'smtp' ? "ck_radio_selected" : ''; ?>">
222 <input class="check_email_mailer_type" type="radio" name="check-email-smtp-options[mailer]" value="smtp" <?php echo $mailer == 'smtp' ? "checked" : ''; ?>>
223 <?php // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?>
224 <img src="<?php echo esc_attr($plugin_dir_url . 'assets/images/smtp.svg') ?>" alt="SMTP Icon">
225 <div class="ce_radio-title"><?php esc_html_e('General SMTP','check-email'); ?></div>
226 </label>
227
228 <label class="ce_radio-label <?php echo $mailer == 'outlook' ? "ck_radio_selected" : ''; ?>" >
229 <input class="check_email_mailer_type" type="radio" name="check-email-smtp-options[mailer]" value="outlook" <?php echo $mailer == 'outlook' ? "checked" : ''; ?>>
230 <?php // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?>
231 <img src="<?php echo esc_attr($plugin_dir_url . 'assets/images/microsoft.svg') ?>" alt="Outlook Icon">
232 <div class="ce_radio-title"><?php esc_html_e('365 / Outlook','check-email'); ?></div>
233 </label>
234 <label class="ce_radio-label <?php echo $mailer == 'gmail' ? "ck_radio_selected" : ''; ?>" >
235 <input class="check_email_mailer_type" type="radio" name="check-email-smtp-options[mailer]" value="gmail" <?php echo $mailer == 'gmail' ? "checked" : ''; ?>>
236 <?php // phpcs:ignore PluginCheck.CodeAnalysis.ImageFunctions.NonEnqueuedImage ?>
237 <img src="<?php echo esc_attr($plugin_dir_url . 'assets/images/gmail.png') ?>" alt="Gmail Icon">
238 <div class="ce_radio-title"><?php esc_html_e('Gmail','check-email'); ?></div>
239 </label>
240 </div>
241 </td>
242 </tr>
243 </thead>
244 <tbody id="check-email-outllook" class="check_email_all_smtp" style="<?php echo $enable_smtp != 'on' || $mailer != 'outlook' ? "display: none" : ''; ?>">
245 <tr class="check_email_smtp_from">
246 <th scope="row"><?php esc_html_e('Application ID', 'check-email'); ?></th>
247 <td>
248 <input class="regular-text" type="text" name="check-email-outlook-options[client_id]" value="<?php echo isset($this->smtp_options['client_id'])?esc_attr(base64_decode($this->smtp_options['client_id'])):"" ?>" >
249 </td>
250 </tr>
251 <tr class="">
252 <th scope="row"><?php esc_html_e('Client Secret', 'check-email'); ?></th>
253 <td>
254 <input class="regular-text" type="password" name="check-email-outlook-options[client_secret]" value="<?php echo isset($this->smtp_options['client_secret'])?esc_attr(base64_decode($this->smtp_options['client_secret'])):"" ?>">
255 </td>
256 </tr>
257 <tr class="">
258 <th scope="row"><?php esc_html_e('Redirect URI', 'check-email'); ?></th>
259 <td>
260
261 <input class="regular-text" type="text" readonly id="check_mail_request_uri" value="<?php echo (is_network_admin()) ? esc_url(network_admin_url()):esc_url(admin_url()) ?>" ><small id="check_mail_copy_text"></small>
262 <p><?php esc_html_e('This is the page on your site that you will be redirected to after you have authenticated with Microsoft. You need to copy this URL into "Authentication > Redirect URIs" web field for your application on Microsoft Azure site for your project there.','check-email'); ?></p>
263 </td>
264 </tr>
265 <tr class="">
266 <td colspan="2">
267 <?php
268
269 if ( $auth->is_clients_saved() ) :
270 if ( $auth->is_auth_required() ) : ?>
271 <a href="<?php echo esc_url( $auth->get_auth_url() ); ?>" class="button button-secondary">
272 <?php esc_html_e( 'Allow plugin to send emails using your Microsoft account', 'check-email' ); ?>
273 </a>
274
275 <?php else : ?>
276
277 <button class="button" id="check_email_remove_outlook">
278 <?php esc_html_e( 'Remove OAuth Connection', 'check-email' ); ?>
279 </button>
280 <span class="">
281 <?php
282 $user = (isset( $this->smtp_options['user_details'] )) ? $this->smtp_options['user_details'] : [];
283
284 if ( isset( $user['email'] ) && isset( $user['display_name'] ) && ! empty( $user['email'] ) && ! empty( $user['display_name'] ) ) {
285 printf(
286 /* translators: %s - Display name and email, as received from oAuth provider. */
287 esc_html__( 'Connected as %s', 'check-email' ),
288 '<code>' . esc_html( $user['display_name'] . ' <' . $user['email'] . '>' ) . '</code>'
289 );
290 }
291 ?>
292 </span>
293 <p class="desc">
294 <?php esc_html_e( 'Removing the OAuth connection will give you an ability to redo the OAuth connection or link to another Microsoft account.', 'check-email' ); ?>
295 </p>
296
297 <?php endif; ?>
298 <?php
299 endif;
300 ?>
301 </td>
302 </tr>
303 </tbody>
304
305 <tbody id="check-email-smtp-form" class="check_email_all_smtp" style="<?php echo $enable_smtp == 'on' && ($mailer == 'smtp' || $mailer == 'gmail') ? "" : 'display: none'; ?>">
306 <tr class="check_email_smtp_from">
307 <th scope="row"><?php esc_html_e('From', 'check-email'); ?></th>
308 <td>
309 <input id="check-email-smtp-from" type="text" name="check-email-smtp-options[smtp_from]" value="<?php echo isset($this->smtp_options['smtp_from'])?esc_attr($this->smtp_options['smtp_from']):"" ?>" size="35">
310 </td>
311 </tr>
312 <tr class="check_email_smtp_from_name">
313 <th scope="row"><?php esc_html_e('From Name', 'check-email'); ?></th>
314 <td>
315 <input id="check-email-smtp-from-name" type="text" name="check-email-smtp-options[smtp_from_name]" size="35" value="<?php echo isset($this->smtp_options['smtp_from_name'])?esc_attr($this->smtp_options['smtp_from_name']):"" ?>">
316 </td>
317 </tr>
318 <tr class="check_email_smtp_host">
319 <th scope="row"><?php esc_html_e('SMTP Host', 'check-email'); ?></th>
320 <td>
321 <input id="check-email-smtp-host" type="text" name="check-email-smtp-options[smtp_host]" value="<?php echo isset($this->smtp_options['smtp_host'])?esc_attr($this->smtp_options['smtp_host']):"" ?>" size="35">
322 </td>
323 </tr>
324 <tr class="check_email_smtp_secure">
325 <th scope="row"><?php esc_html_e('SMTP Secure', 'check-email'); ?></th>
326 <td>
327 <?php
328 $secure_array = array('None' => '', 'SSL' => 'ssl', 'TLS' => 'tls');
329 $field_value = isset($this->smtp_options['smtp_secure'])?$this->smtp_options['smtp_secure']:"";
330 foreach ($secure_array as $sa_key => $sa_value) {
331 $checked = '';
332 $id = 'check-email-smtp-secure';
333 if($sa_value == 'ssl'){
334 $id = 'check-email-smtp-secure-ssl';
335 }else if($sa_value == 'tls'){
336 $id = 'check-email-smtp-secure-tls';
337 }
338 if($field_value == $sa_value){
339 $checked = 'checked';
340 }
341
342 ?>
343 <label for="<?php echo esc_attr($id); ?>" class="check-mail-smtp-secure-label">
344 <input id="<?php echo esc_attr($id); ?>" type="radio" name="check-email-smtp-options[smtp_secure]" value="<?php echo esc_attr($sa_value); ?>" <?php echo esc_attr($checked); ?>> <?php echo esc_html($sa_key); ?> </label>
345 <?php
346 }
347 ?>
348 </td>
349 </tr>
350 <tr class="check_email_smtp_port">
351 <?php $smtp_port = isset($this->smtp_options['smtp_port'])?$this->smtp_options['smtp_port']:""; ?>
352 <th scope="row"><?php esc_html_e('SMTP Port', 'check-email'); ?></th>
353 <td>
354 <input id="check-email-smtp-port" type="text" name="check-email-smtp-options[smtp_port]" value="<?php echo esc_attr($smtp_port) ?>" size="35">
355 </td>
356 </tr>
357 <tr class="check_email_smtp_auth">
358 <th scope="row"><?php esc_html_e('SMTP Authentication', 'check-email'); ?></th>
359 <td>
360 <?php
361 $secure_array = array('No' => 'no', 'Yes' => 'yes');
362 $field_value = isset($this->smtp_options['smtp_auth'])?$this->smtp_options['smtp_auth']:"yes";
363
364 foreach ($secure_array as $sa_key => $sa_value) {
365 $checked = '';
366 $id = 'check-email-smtp-secure-yes';
367 if($sa_value == 'no'){
368 $id = 'check-email-smtp-secure-no';
369 }
370 if($field_value == $sa_value){
371 $checked = 'checked';
372 }
373 ?>
374 <label for="<?php echo esc_attr($id); ?>" class="check-mail-smtp-secure-label">
375 <input id="<?php echo esc_attr($id); ?>" type="radio" name="check-email-smtp-options[smtp_auth]" value="<?php echo esc_attr($sa_value); ?>" <?php echo esc_attr($checked); ?>> <?php echo esc_html($sa_key); ?> </label>
376 <?php
377 }
378 ?>
379 </td>
380 </tr>
381 <tr class="check_email_smtp_username">
382 <th scope="row"><?php esc_html_e('Username', 'check-email'); ?></th>
383 <?php $smtp_username = isset($this->smtp_options['smtp_username'])?base64_decode($this->smtp_options['smtp_username']):''; ?>
384 <td>
385 <input id="check-email-smtp-username" type="text" name="check-email-smtp-options[smtp_username]" value="<?php echo esc_attr($smtp_username); ?>" size="35">
386 </td>
387 </tr>
388 <tr class="check_email_smtp_password">
389 <th scope="row"><?php esc_html_e('Password', 'check-email'); ?></th>
390 <?php $smtp_password = isset($this->smtp_options['smtp_password'])?base64_decode($this->smtp_options['smtp_password']):''; ?>
391 <td>
392 <input id="check-email-smtp-password" type="password" name="check-email-smtp-options[smtp_password]" value="<?php echo esc_attr($smtp_password); ?>" size="35">
393 </td>
394 </tr>
395 </tbody>
396 </table>
397 </div>
398 <?php wp_nonce_field('check_mail_smtp_nonce','check_mail_smtp_nonce'); ?>
399 <p class="submit"><input type="submit" name="check_mail_smtp_submit" id="check_mail_smtp_submit" class="button button-primary" value="<?php esc_attr_e( 'Save', 'check-email' ); ?>"></p>
400 </form>
401 <?php
402 }
403
404 /**
405 * Save SMTP options
406 *
407 * @return void
408 * @since 1.0.12
409 */
410
411 public function smtp_form_submission_handler(){
412 if(isset($_POST['check_mail_smtp_submit']) && $_POST['check_mail_smtp_submit'] == 'Save'){
413 if(!isset($_POST['check_mail_smtp_nonce'])){
414 return;
415 }
416
417 if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['check_mail_smtp_nonce'] ) ), 'check_mail_smtp_nonce' ) ){
418 return;
419 }
420
421 if ( ! current_user_can( 'manage_check_email' ) ) {
422 return;
423 }
424 if ( isset( $_POST['check-email-smtp-options']) ) {
425 $smtp_password = "";
426 if ( isset($_POST['check-email-smtp-options']['smtp_password']) && !empty( $_POST['check-email-smtp-options']['smtp_password'] ) ) {
427 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason this is the password, sanitization is not needed here
428 $smtp_password = wp_unslash($_POST['check-email-smtp-options']['smtp_password']);
429 }
430 $smtp_opt = array_map('sanitize_text_field', wp_unslash($_POST['check-email-smtp-options']));
431
432 if ( $smtp_opt['mailer'] == 'outlook' && isset( $_POST['check-email-outlook-options'] ) ) {
433 $outlook_option = array_map('sanitize_text_field', wp_unslash($_POST['check-email-outlook-options']));
434 if(isset($outlook_option['client_id']) && !empty($outlook_option['client_id'])){
435 $outlook_option['client_id'] = base64_encode($outlook_option['client_id']);
436 }
437 if(isset($outlook_option['client_secret']) && !empty($outlook_option['client_secret'])){
438 $outlook_option['client_secret'] = base64_encode($outlook_option['client_secret']);
439 }
440 $auth = new Auth( 'outlook' );
441 $auth->update_mailer_option( $outlook_option );
442 }else{
443 if(isset($smtp_opt['smtp_username']) && !empty($smtp_opt['smtp_username'])){
444 $smtp_opt['smtp_username'] = base64_encode($smtp_opt['smtp_username']);
445 }
446 if(isset($smtp_opt['smtp_password']) && !empty($smtp_opt['smtp_password'])){
447 $smtp_opt['smtp_password'] = base64_encode($smtp_password);
448 }
449 }
450 update_option('check-email-smtp-options', $smtp_opt);
451 delete_option( 'check_email_smtp_status' );
452 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
453 do_action( 'check_mail_smtp_admin_update' );
454
455 wp_safe_redirect(admin_url('admin.php?page=check-email-settings&tab=smtp'));
456 }
457 }
458 }
459
460 /**
461 * Add notice to retype credentials and info about the server
462 *
463 * @return void
464 * @since 1.0.12
465 */
466 public function retype_credentials_notice() {
467
468 $status = get_option( 'check_email_smtp_status' );
469
470 if ( ! $status || 'not_encrypted' !== $status) {
471 return;
472 }
473
474 ?>
475 <div class="notice notice-error is-dismissible">
476 <h3><?php esc_html_e( 'Check Mail SMTP connection error', 'check-email' ); ?></h3>
477 <p><?php esc_html_e( 'Seems like there are some problems with the enterd information. Please re-check & re-enter it and hit the "Save changes" button.', 'check-email' ); ?></p>
478 </div>
479 <?php
480 }
481 public function check_email_remove_outlook() {
482
483 if(!isset($_POST['ck_mail_security_nonce'])){
484 return;
485 }
486
487 if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['ck_mail_security_nonce'] ) ), 'ck_mail_security_nonce' ) ){
488 return;
489 }
490
491
492 if ( ! current_user_can( 'manage_check_email' ) ) {
493 return;
494 }
495 $auth = new Auth('outlook');
496 $auth->delete_outlook_options();
497 echo wp_json_encode(array('status'=> 200));
498 wp_die();
499 }
500 }
501 new Check_Email_SMTP_Tab();