From 314850eb26c03138b13c0173ef5328aff28745f3 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Tue, 14 Dec 2021 17:10:45 +0000 Subject: [PATCH 01/26] develop branch rep. --- readme.txt | 2 ++ wp-simple-smtp.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 13e2dbb..54bb405 100644 --- a/readme.txt +++ b/readme.txt @@ -83,6 +83,8 @@ To help diagnose disabled input boxes, when the WordPress site is in [debugging Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-simple-smtp) for writing issues and/or making pull requests. == Changelog == += Edge = + = 1.2.3 = * Add: [WordPress CLI](https://wp-cli.org/) support. See the FAQ for usage details. * Change: Password not returned plaintext in settings ([#61](https://github.com/soup-bowl/wp-simple-smtp/issues/61)). diff --git a/wp-simple-smtp.php b/wp-simple-smtp.php index dc8cb7e..caa2058 100644 --- a/wp-simple-smtp.php +++ b/wp-simple-smtp.php @@ -10,7 +10,7 @@ * Plugin Name: Simple SMTP * Description: Adds mail configuration to WordPress in a simple, standardised plugin. * Plugin URI: https://www.soupbowl.io/wp-plugins - * Version: 1.2.3 + * Version: edge * Author: soup-bowl * Author URI: https://www.soupbowl.io * License: MIT From 698a14bdc60c00d6e7f8f3682563920fae29d70b Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Tue, 14 Dec 2021 17:11:33 +0000 Subject: [PATCH 02/26] Amended workflow. --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 566d18b..773efa9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,9 @@ name: Per-commit CI Test on: push: - branches: [ main ] + branches: + - main + - develop workflow_dispatch: jobs: From b77f836d3d02f4355036366cd5b276937cd9e1aa Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Tue, 14 Dec 2021 22:42:10 +0000 Subject: [PATCH 03/26] Added CLI email viewer. --- src/cli/class-emaillog.php | 26 +++++++++++++++++++++++++- src/log/class-logservice.php | 2 +- wp-simple-smtp.php | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/cli/class-emaillog.php b/src/cli/class-emaillog.php index d85661d..001704a 100644 --- a/src/cli/class-emaillog.php +++ b/src/cli/class-emaillog.php @@ -79,13 +79,37 @@ public function load_log( $args, $assoc_args ) { } } + /** + * Displays the contents of an email. + * + * + * : ID of the email you wish to load up. + * + * @when before_wp_load + * + * @param array $args Command-line arguments. + * @param array $assoc_args Associated arguments. + */ + public function view_email( $args, $assoc_args ) { + $email = $this->log_service->get_log_entry_by_id( (int) $args[0] ); + if ( ! empty( $email ) ) { + WP_CLI::line( 'Recipient(s): ' . implode( ', ', $email->get_recipients() ) ); + WP_CLI::line( 'Subject: ' . $email->get_subject() ); + WP_CLI::line( 'Headers: ' . implode( ', ', $email->get_headers() ) ); + WP_CLI::line( 'Contents:' ); + WP_CLI::line( $email->get_body() ); + } else { + WP_CLI::error( __( 'Email not found.', 'simple-smtp' ) ); + } + } + /** * Generates a CLI output list of entries derrived from the input. * * @param Log[] $entries Log entry collection. * @return void Prints the log to the page. */ - public function list( $entries ) { + private function list( $entries ) { $list_format = []; foreach ( $entries as $entry ) { $list_format[] = [ diff --git a/src/log/class-logservice.php b/src/log/class-logservice.php index 05e49a4..4d4e817 100644 --- a/src/log/class-logservice.php +++ b/src/log/class-logservice.php @@ -228,7 +228,7 @@ public function delete_all_logs_to_email( $email ) { * @return Log */ private function wp_to_obj( $post ) { - if ( empty( $post ) ) { + if ( empty( $post ) || $this->post_type !== $post->post_type ) { return null; } diff --git a/wp-simple-smtp.php b/wp-simple-smtp.php index caa2058..ab11576 100644 --- a/wp-simple-smtp.php +++ b/wp-simple-smtp.php @@ -45,6 +45,7 @@ function() { if ( defined( 'WP_CLI' ) && WP_CLI ) { WP_CLI::add_command( 'email-test', [ new wpsimplesmtp\cli\EmailTest(), 'test_email' ] ); WP_CLI::add_command( 'email-log', [ new wpsimplesmtp\cli\EmailLog(), 'load_log' ] ); + WP_CLI::add_command( 'email-view', [ new wpsimplesmtp\cli\EmailLog(), 'view_email' ] ); } if ( is_admin() ) { From 6821857cb1cd2126ccc5de98854e5c1f301b8651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Chantre?= Date: Mon, 20 Dec 2021 21:34:26 +0100 Subject: [PATCH 04/26] Use a capability name with current_user_can() --- src/settings/class-mailview.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/class-mailview.php b/src/settings/class-mailview.php index 52173ac..94113ae 100644 --- a/src/settings/class-mailview.php +++ b/src/settings/class-mailview.php @@ -46,7 +46,7 @@ public function render_email_view( $id ) { menu_page_url( 'wpsimplesmtp', false ) ) . '&resend'; - if ( current_user_can( 'administrator' ) && isset( $log ) ) { + if ( current_user_can( 'manage_options' ) && isset( $log ) ) { $recipients = implode( ', ', $log->get_recipients() ); $date = gmdate( get_option( 'time_format' ) . ', ' . get_option( 'date_format' ), strtotime( $log->get_timestamp() ) ); From f657d940a742fc8766f887910aa63f06af0c6f65 Mon Sep 17 00:00:00 2001 From: Casey Date: Tue, 21 Dec 2021 11:24:49 +0000 Subject: [PATCH 05/26] Update readme.txt --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 54bb405..8339067 100644 --- a/readme.txt +++ b/readme.txt @@ -84,6 +84,7 @@ Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-sim == Changelog == = Edge = +* Fix: Incorrect capability type used by the log viewer. Thanks to [Benoît Chantre](https://github.com/benoitchantre) [#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74). = 1.2.3 = * Add: [WordPress CLI](https://wp-cli.org/) support. See the FAQ for usage details. From 9225dc980b35aa76ea15527caab6ac94a683d623 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 9 Jan 2022 15:27:57 +0000 Subject: [PATCH 06/26] Suggested perm change from #74. --- readme.txt | 1 + src/log/class-logservice.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 8339067..33d3572 100644 --- a/readme.txt +++ b/readme.txt @@ -84,6 +84,7 @@ Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-sim == Changelog == = Edge = +* Change: Tightened permissions to the log viewer ([#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74)). * Fix: Incorrect capability type used by the log viewer. Thanks to [Benoît Chantre](https://github.com/benoitchantre) [#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74). = 1.2.3 = diff --git a/src/log/class-logservice.php b/src/log/class-logservice.php index 05e49a4..a8c303b 100644 --- a/src/log/class-logservice.php +++ b/src/log/class-logservice.php @@ -36,7 +36,21 @@ public function __construct() { * Register the log storage CPT within WordPress. */ public function register_log_storage() { - register_post_type( $this->post_type ); + register_post_type( + $this->post_type, + [ + 'capabilities' => [ + 'publish_posts' => 'manage_options', + 'edit_others_posts' => 'manage_options', + 'delete_posts' => 'manage_options', + 'delete_others_posts' => 'manage_options', + 'read_private_posts' => 'manage_options', + 'edit_post' => 'manage_options', + 'delete_post' => 'manage_options', + 'read_post' => 'manage_options', + ], + ] + ); } /** From 95121d90f870ff296c30c321c98b95e9ba9511bd Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 9 Jan 2022 16:22:52 +0000 Subject: [PATCH 07/26] Purge logs on deactivation (doesn't cover whole MS on network deacivate). --- wp-simple-smtp.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/wp-simple-smtp.php b/wp-simple-smtp.php index caa2058..dbf3bd3 100644 --- a/wp-simple-smtp.php +++ b/wp-simple-smtp.php @@ -94,6 +94,9 @@ function wpsmtp_deactivation() { wp_next_scheduled( 'wpss_clear_resent' ), 'wpss_clear_resent' ); + + // Clear out remaining log files upon deactivation. + ( new LogService() )->delete_all_logs(); } /** From f4f41e9f032160c17f293a65f49f22abd95dbca0 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Thu, 13 Jan 2022 00:09:48 +0000 Subject: [PATCH 08/26] Adjusted QC to use local not remote config. --- assets/smtp-config.js | 23 +++++++++------------- wp-simple-smtp.php | 46 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/assets/smtp-config.js b/assets/smtp-config.js index 3ec3615..0c097fb 100644 --- a/assets/smtp-config.js +++ b/assets/smtp-config.js @@ -13,15 +13,10 @@ const { __, _x, _n, _nx } = wp.i18n; */ function wpss_loadin() { if ( null !== document.getElementById( 'wpss-conf' ) ) { - jQuery.getJSON( - "https://www.soupbowl.io/wp-json/wprass/v1/sources", - function( data ) { - wpss_load_quicksettings( data ); - document.getElementById( 'wpss-quickset' ).onchange = function( stuff ) { - wpss_input_selection( data, stuff.target.value ); - }; - } - ); + wpss_load_quicksettings( wpss_qc_settings ); + document.getElementById( 'wpss-quickset' ).onchange = function( stuff ) { + wpss_input_selection( wpss_qc_settings, stuff.target.value ); + }; } } @@ -47,10 +42,10 @@ function wpss_load_quicksettings( data ) { selector_c1.outerHTML = "" + __( 'Quick Config', 'simple-smtp' ) + ""; // Content cell. - var datacount = data.configurations.length; + var datacount = data.length; options += ''; for (i = 0; i < datacount; i++) { - options += ''; + options += ''; } selector.innerHTML = options; selector_c2.appendChild( selector ); @@ -69,10 +64,10 @@ function wpss_load_quicksettings( data ) { */ function wpss_input_selection( data, name ) { var s = null; - var c = data.configurations.length; + var c = data.length; for (i = 0; i < c; i++) { - if ( data.configurations[i].name == name ) { - s = data.configurations[i]; + if ( data[i].name == name ) { + s = data[i]; break; } } diff --git a/wp-simple-smtp.php b/wp-simple-smtp.php index caa2058..651d749 100644 --- a/wp-simple-smtp.php +++ b/wp-simple-smtp.php @@ -71,6 +71,52 @@ function ( $page ) { wp_enqueue_style( 'wpss_admin_css', plugin_dir_url( __FILE__ ) . 'assets/smtp-config.css', [], '1.2' ); wp_enqueue_script( 'wpss_config', plugin_dir_url( __FILE__ ) . 'assets/smtp-config.js', [ 'jquery', 'wp-i18n' ], '1.3', true ); wp_set_script_translations( 'wpss_config', 'simple-smtp' ); + + $smtp_settings = [ + [ + 'name' => 'Gmail', + 'server' => 'smtp.gmail.com', + 'port' => '587', + 'authentication' => true, + 'encryption' => 'tls', + ], + [ + 'name' => 'Microsoft Exchange', + 'server' => 'smtp.office365.com', + 'port' => '587', + 'authentication' => true, + 'encryption' => 'tls', + ], + [ + 'name' => 'SendGrid', + 'server' => 'smtp.sendgrid.net', + 'port' => '587', + 'authentication' => true, + 'user' => 'apikey', + 'encryption' => 'tls', + ], + [ + 'name' => 'Pepipost', + 'server' => 'smtp.pepipost.com', + 'port' => '587', + 'authentication' => true, + ], + [ + 'name' => 'SendinBlue', + 'server' => 'smtp-relay.sendinblue.com', + 'port' => '587', + 'authentication' => true, + ], + [ + 'name' => 'Amazon SES', + 'server' => 'email-smtp..amazonaws.com', + 'port' => '465', + 'authentication' => true, + 'encryption' => 'tls', + ], + ]; + + wp_localize_script( 'wpss_config', 'wpss_qc_settings', $smtp_settings ); } } ); From 7b18f12d2ca7e989b7d4beeb65095cb8ccba3a00 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Thu, 13 Jan 2022 00:17:00 +0000 Subject: [PATCH 09/26] Moved config to a class. --- src/settings/class-quickconfig.php | 66 ++++++++++++++++++++++++++++++ wp-simple-smtp.php | 45 +------------------- 2 files changed, 68 insertions(+), 43 deletions(-) create mode 100644 src/settings/class-quickconfig.php diff --git a/src/settings/class-quickconfig.php b/src/settings/class-quickconfig.php new file mode 100644 index 0000000..519077b --- /dev/null +++ b/src/settings/class-quickconfig.php @@ -0,0 +1,66 @@ + + * @license MIT + */ + +namespace wpsimplesmtp; + +/** + * Configuration applicable to the quick config segment. + */ +class QuickConfig { + /** + * Returns an array of possible SMTP configuration options. + * + * @return array + */ + public static function settings() { + return [ + [ + 'name' => 'Gmail', + 'server' => 'smtp.gmail.com', + 'port' => '587', + 'authentication' => true, + 'encryption' => 'tls', + ], + [ + 'name' => 'Microsoft Exchange', + 'server' => 'smtp.office365.com', + 'port' => '587', + 'authentication' => true, + 'encryption' => 'tls', + ], + [ + 'name' => 'SendGrid', + 'server' => 'smtp.sendgrid.net', + 'port' => '587', + 'authentication' => true, + 'user' => 'apikey', + 'encryption' => 'tls', + ], + [ + 'name' => 'Pepipost', + 'server' => 'smtp.pepipost.com', + 'port' => '587', + 'authentication' => true, + ], + [ + 'name' => 'SendinBlue', + 'server' => 'smtp-relay.sendinblue.com', + 'port' => '587', + 'authentication' => true, + ], + [ + 'name' => 'Amazon SES', + 'server' => 'email-smtp..amazonaws.com', + 'port' => '465', + 'authentication' => true, + 'encryption' => 'tls', + ], + ]; + } +} diff --git a/wp-simple-smtp.php b/wp-simple-smtp.php index 651d749..bf5b08a 100644 --- a/wp-simple-smtp.php +++ b/wp-simple-smtp.php @@ -19,6 +19,7 @@ use wpsimplesmtp\LogService; use wpsimplesmtp\Singular as Settings; use wpsimplesmtp\Multisite as SettingsMultisite; +use wpsimplesmtp\QuickConfig; use wpsimplesmtp\Privacy; use wpsimplesmtp\Mail; use wpsimplesmtp\MailDisable; @@ -72,49 +73,7 @@ function ( $page ) { wp_enqueue_script( 'wpss_config', plugin_dir_url( __FILE__ ) . 'assets/smtp-config.js', [ 'jquery', 'wp-i18n' ], '1.3', true ); wp_set_script_translations( 'wpss_config', 'simple-smtp' ); - $smtp_settings = [ - [ - 'name' => 'Gmail', - 'server' => 'smtp.gmail.com', - 'port' => '587', - 'authentication' => true, - 'encryption' => 'tls', - ], - [ - 'name' => 'Microsoft Exchange', - 'server' => 'smtp.office365.com', - 'port' => '587', - 'authentication' => true, - 'encryption' => 'tls', - ], - [ - 'name' => 'SendGrid', - 'server' => 'smtp.sendgrid.net', - 'port' => '587', - 'authentication' => true, - 'user' => 'apikey', - 'encryption' => 'tls', - ], - [ - 'name' => 'Pepipost', - 'server' => 'smtp.pepipost.com', - 'port' => '587', - 'authentication' => true, - ], - [ - 'name' => 'SendinBlue', - 'server' => 'smtp-relay.sendinblue.com', - 'port' => '587', - 'authentication' => true, - ], - [ - 'name' => 'Amazon SES', - 'server' => 'email-smtp..amazonaws.com', - 'port' => '465', - 'authentication' => true, - 'encryption' => 'tls', - ], - ]; + $smtp_settings = QuickConfig::settings(); wp_localize_script( 'wpss_config', 'wpss_qc_settings', $smtp_settings ); } From 9147ef0c4eeeef02286f7b2cd5ab77ec899d64a7 Mon Sep 17 00:00:00 2001 From: Casey Date: Thu, 13 Jan 2022 23:10:42 +0000 Subject: [PATCH 10/26] Update readme.txt --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 8339067..bdbe77b 100644 --- a/readme.txt +++ b/readme.txt @@ -84,6 +84,7 @@ Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-sim == Changelog == = Edge = +* Change: Quick config settings now contained within plugin ([#78](https://github.com/soup-bowl/wp-simple-smtp/issues/78)). * Fix: Incorrect capability type used by the log viewer. Thanks to [Benoît Chantre](https://github.com/benoitchantre) [#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74). = 1.2.3 = From 17d336f6f2ccb0dc477e90aee2330ae3880146a3 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 02:00:14 +0000 Subject: [PATCH 11/26] Modified quickstart for crons. --- .docker/quickstart.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.docker/quickstart.sh b/.docker/quickstart.sh index 077a8b1..c7af9df 100644 --- a/.docker/quickstart.sh +++ b/.docker/quickstart.sh @@ -8,3 +8,7 @@ fi if [ "$1" == "beta" ]; then wp core update --version=nightly --allow-root fi + +wp plugin install wp-crontrol --allow-root + +wp plugin activate simple-smtp wp-crontrol --allow-root From a030ca343331683247d31df793b1bb9a246a0501 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 02:17:50 +0000 Subject: [PATCH 12/26] (#71) Purge logs older than a month. --- src/log/class-logservice.php | 24 ++++++++++++++++++++++++ wp-simple-smtp.php | 12 ++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/log/class-logservice.php b/src/log/class-logservice.php index 05e49a4..549245f 100644 --- a/src/log/class-logservice.php +++ b/src/log/class-logservice.php @@ -191,6 +191,30 @@ public function delete_all_logs() { return true; } + /** + * Prunes the log collection based on the specified time interval. + * + * @param integer $int_time_diff After this UNIX timeframe difference will be removed. + * @return boolean + */ + public function prune_logs( $int_time_diff ) { + $all = get_posts( + array( + 'post_type' => $this->post_type, + 'numberposts' => -1, + 'date_query' => [ + 'before' => date( 'Y-m-d', ( time() - $int_time_diff ) ) + ], + ) + ); + + foreach ( $all as $log ) { + wp_delete_post( $log->ID ); + } + + return true; + } + /** * Deletes all log entries relating to a certain email address. * diff --git a/wp-simple-smtp.php b/wp-simple-smtp.php index dbf3bd3..54889c0 100644 --- a/wp-simple-smtp.php +++ b/wp-simple-smtp.php @@ -64,6 +64,14 @@ function() { } ); +add_action( + 'wpss_clear_logs', + function() { + // 2629800 = 1 Month. + ( new LogService() )->prune_logs( 2629800 ); + } +); + add_action( 'admin_enqueue_scripts', function ( $page ) { @@ -84,6 +92,10 @@ function wpsmtp_activation() { if ( ! wp_next_scheduled( 'wpss_clear_resent' ) ) { wp_schedule_event( time(), 'hourly', 'wpss_clear_resent' ); } + + if ( ! wp_next_scheduled( 'wpss_clear_logs' ) ) { + wp_schedule_event( time(), 'hourly', 'wpss_clear_logs' ); + } } /** From 632709687a908a9d97ababdb7a9574d05b8c2363 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 02:32:12 +0000 Subject: [PATCH 13/26] Added log clear escape hook. --- readme.txt | 8 ++++++++ wp-simple-smtp.php | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 8339067..ccf80c7 100644 --- a/readme.txt +++ b/readme.txt @@ -52,6 +52,13 @@ The over-ride hierachy is as follows, with top being the most important. * Multisite network settings. * Locally-configured settings. += How do I stop the logs auto-prune? = +Register the following hook (typically in your theme functions.php) to disable the auto-pruning functionality: + +``` +add_filter( 'simple_smtp_disable_log_prune', '__return_true' ); +``` + = How is the SMTP password stored? = If openssl is available to PHP, then the password will be **encrypted** ([not hashed](https://stackoverflow.com/a/4948393)) when stored in the database. If unavailable, the SMTP password will be saved into the database as **plaintext**. The more recommended way of storing the password is to define SMTP_PASS in your wp-config.php file, which should already be locked and inaccessible from the front-end. @@ -84,6 +91,7 @@ Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-sim == Changelog == = Edge = +* Change: (For new installs) logs purge automatically after a month ([#70](https://github.com/soup-bowl/wp-simple-smtp/issues/70), [#71](https://github.com/soup-bowl/wp-simple-smtp/issues/71)) * Fix: Incorrect capability type used by the log viewer. Thanks to [Benoît Chantre](https://github.com/benoitchantre) [#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74). = 1.2.3 = diff --git a/wp-simple-smtp.php b/wp-simple-smtp.php index 54889c0..8bb351a 100644 --- a/wp-simple-smtp.php +++ b/wp-simple-smtp.php @@ -67,8 +67,11 @@ function() { add_action( 'wpss_clear_logs', function() { + $is_disabled = apply_filters( 'simple_smtp_disable_log_prune', false ); // 2629800 = 1 Month. - ( new LogService() )->prune_logs( 2629800 ); + if ( ! $is_disabled ) { + ( new LogService() )->prune_logs( 2629800 ); + } } ); From bbf87cbe5978a9aa2bcf964bde1d0f61cc844d2e Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 02:36:00 +0000 Subject: [PATCH 14/26] phpcs/codefactor fix suggestion. --- src/log/class-logservice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/log/class-logservice.php b/src/log/class-logservice.php index 549245f..6cb425f 100644 --- a/src/log/class-logservice.php +++ b/src/log/class-logservice.php @@ -203,7 +203,7 @@ public function prune_logs( $int_time_diff ) { 'post_type' => $this->post_type, 'numberposts' => -1, 'date_query' => [ - 'before' => date( 'Y-m-d', ( time() - $int_time_diff ) ) + 'before' => gmdate( 'Y-m-d', ( time() - $int_time_diff ) ), ], ) ); From 8f35b0916eede60bdfd99ce9e3057eee34cce569 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 02:48:32 +0000 Subject: [PATCH 15/26] Excluded ms docker from Codesnff. --- phpcs.xml.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 81f37b7..1cf7755 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,6 +1,7 @@ /vendor/* + /.docker/* From aefaf0f79fa1ea4c58cc66d371a5fed7ec59947e Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 03:00:21 +0000 Subject: [PATCH 16/26] Tested against 5.9 (closes #68) --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 81b3c6c..94a9c8d 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: soupbowl Tags: mail,email,smtp,dispatch,sender Requires at least: 4.9 -Tested up to: 5.8 +Tested up to: 5.9 Requires PHP: 7.0 Stable tag: 1.2.3 License: MIT From 8b96b927953718744ecc4afbea5fccc0fe9d72a7 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 03:13:09 +0000 Subject: [PATCH 17/26] Added SMTP report to GH ssues. --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/smtp_report.md | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE/smtp_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8274eca..57a144c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -24,4 +24,4 @@ Steps to reproduce the behavior: A clear and concise description of what you expected to happen. **Screenshots** -If applicable, add screenshots to help explain your problem. \ No newline at end of file +If applicable, add screenshots to help explain your problem. diff --git a/.github/ISSUE_TEMPLATE/smtp_report.md b/.github/ISSUE_TEMPLATE/smtp_report.md new file mode 100644 index 0000000..478882b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/smtp_report.md @@ -0,0 +1,14 @@ +--- +name: Report missing/incorrect SMTP settings +about: Report issues with the Quick Config SMTP chooser. +title: '' +labels: smtp-setting +assignees: '' + +--- + +**Is this a new suggestion or an edit to an existing option?** + + +**What is your update/replacement suggestion?** + From f7acf9354d668c2d0b32ee2a5511352c99cdc630 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 03:41:33 +0000 Subject: [PATCH 18/26] Added test email feedback (Fixes #81) --- src/cli/class-emailtest.php | 4 ++-- src/mail/class-mailtest.php | 13 ++++++++++--- src/settings/class-singular.php | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/cli/class-emailtest.php b/src/cli/class-emailtest.php index dff900c..dd073f0 100644 --- a/src/cli/class-emailtest.php +++ b/src/cli/class-emailtest.php @@ -41,9 +41,9 @@ public function test_email( $args, $assoc_args ) { $is_sent = wp_mail( $recipient, $email['subject'], $email['message'], $email['headers'] ); if ( $is_sent ) { - WP_CLI::success( __( 'Test email sent!', 'simple-smtp' ) ); + WP_CLI::success( __( 'Test email sent successfully.', 'simple-smtp' ) ); } else { - WP_CLI::error( __( 'Email failed to send. Check the logs to see what happened.', 'simple-smtp' ) ); + WP_CLI::error( __( 'Test email failed. Please check your configuration and try again.', 'simple-smtp' ) ); } } else { WP_CLI::error( __( 'Email address provided is invalid.', 'simple-smtp' ) ); diff --git a/src/mail/class-mailtest.php b/src/mail/class-mailtest.php index 537f19e..c372dca 100644 --- a/src/mail/class-mailtest.php +++ b/src/mail/class-mailtest.php @@ -90,9 +90,16 @@ public static function test_email_handler() { $recipients[ $i ] = sanitize_email( trim( $recipients[ $i ] ) ); } - wp_mail( $recipients, $email['subject'], $email['message'], $email['headers'] ); - - wp_safe_redirect( admin_url( 'options-general.php?page=wpsimplesmtp' ) ); + $success = wp_mail( $recipients, $email['subject'], $email['message'], $email['headers'] ); + + wp_safe_redirect( + add_query_arg( + [ + 'status' => ( $success ) ? 'pass' : 'fail', + ], + admin_url( 'options-general.php?page=wpsimplesmtp' ) + ) + ); exit; } else { wp_die( esc_attr_e( 'You are not permitted to send a test email.', 'simple-smtp' ) ); diff --git a/src/settings/class-singular.php b/src/settings/class-singular.php index 9c3cc54..c44d01c 100644 --- a/src/settings/class-singular.php +++ b/src/settings/class-singular.php @@ -257,6 +257,23 @@ private function render_settings() { can_edit_settings( 'wpssmtp_disable_settings' ) ) : ?>

{$notice}

", + [ + 'div' => [ + 'class' => [], + ], + 'p' => [], + 'strong' => [], + ] + ); + } + settings_fields( 'wpsimplesmtp_smtp' ); do_settings_sections( 'wpsimplesmtp_smtp' ); submit_button(); From de63a6eaed0abf3c0ecbda9307ee56f80dc366a6 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 03:48:27 +0000 Subject: [PATCH 19/26] Adjusted readme. --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 94a9c8d..30d3c92 100644 --- a/readme.txt +++ b/readme.txt @@ -84,6 +84,7 @@ Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-sim == Changelog == = Edge = +* Added: Status message from testing emails ([#81](https://github.com/soup-bowl/wp-simple-smtp/issues/81)). * Change: Quick config settings now contained within plugin ([#78](https://github.com/soup-bowl/wp-simple-smtp/issues/78)). * Change: Tightened permissions to the log viewer ([#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74)). * Fix: Incorrect capability type used by the log viewer. Thanks to [Benoît Chantre](https://github.com/benoitchantre) [#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74). From bf4aa65e2a3a9449f0ffd05b54044d118b7212a8 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 03:53:16 +0000 Subject: [PATCH 20/26] phpcs fix. --- src/log/class-logservice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/log/class-logservice.php b/src/log/class-logservice.php index 4d4e817..c9d979b 100644 --- a/src/log/class-logservice.php +++ b/src/log/class-logservice.php @@ -228,7 +228,7 @@ public function delete_all_logs_to_email( $email ) { * @return Log */ private function wp_to_obj( $post ) { - if ( empty( $post ) || $this->post_type !== $post->post_type ) { + if ( empty( $post ) || $this->post_type !== $post->post_type ) { return null; } From c67cc958747f904313cfd3dd9f902e3edc58666d Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 16 Jan 2022 03:54:30 +0000 Subject: [PATCH 21/26] readme updaye. --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index 54bb405..d2f8200 100644 --- a/readme.txt +++ b/readme.txt @@ -84,6 +84,7 @@ Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-sim == Changelog == = Edge = +* Add: Read logged emails via WP-CLI. = 1.2.3 = * Add: [WordPress CLI](https://wp-cli.org/) support. See the FAQ for usage details. From 9698896b041757bc056d51c4058dc303736856d8 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Tue, 18 Jan 2022 21:31:56 +0000 Subject: [PATCH 22/26] Added mock condition for new PT check. --- tests/log/class-logservice-test.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/log/class-logservice-test.php b/tests/log/class-logservice-test.php index a77c820..e66a03a 100644 --- a/tests/log/class-logservice-test.php +++ b/tests/log/class-logservice-test.php @@ -67,6 +67,13 @@ class WP_Post { * @var string */ public $post_content = 'Example Content'; + + /** + * Post Type. + * + * @var string + */ + public $post_type = 'sbss_email_log'; } /** From e7345c15f6fcc5295515dd831725056fdec527ad Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Tue, 18 Jan 2022 21:35:06 +0000 Subject: [PATCH 23/26] Readme updated for release. --- readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index a727a70..0226c21 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: mail,email,smtp,dispatch,sender Requires at least: 4.9 Tested up to: 5.9 Requires PHP: 7.0 -Stable tag: 1.2.3 +Stable tag: 1.2.4 License: MIT Adds a simple mail configuration panel into your WordPress installation. Supports logging and config variables. @@ -90,7 +90,7 @@ To help diagnose disabled input boxes, when the WordPress site is in [debugging Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-simple-smtp) for writing issues and/or making pull requests. == Changelog == -= Edge = += 1.2.4 = * Added: Read logged emails via WP-CLI. * Added: Status message from testing emails ([#81](https://github.com/soup-bowl/wp-simple-smtp/issues/81)). * Change: (For new installs) logs purge automatically after a month ([#70](https://github.com/soup-bowl/wp-simple-smtp/issues/70), [#71](https://github.com/soup-bowl/wp-simple-smtp/issues/71)). From 212532d7e2a1250f1d9c02763adfa8e9f31ae673 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Tue, 18 Jan 2022 21:51:20 +0000 Subject: [PATCH 24/26] 70/71 split - they're not related isseus. --- readme.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 0226c21..f779e56 100644 --- a/readme.txt +++ b/readme.txt @@ -93,7 +93,8 @@ Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-sim = 1.2.4 = * Added: Read logged emails via WP-CLI. * Added: Status message from testing emails ([#81](https://github.com/soup-bowl/wp-simple-smtp/issues/81)). -* Change: (For new installs) logs purge automatically after a month ([#70](https://github.com/soup-bowl/wp-simple-smtp/issues/70), [#71](https://github.com/soup-bowl/wp-simple-smtp/issues/71)). +* Change: Uninstalling the plugin will remove the lingering logs ([#70](https://github.com/soup-bowl/wp-simple-smtp/issues/70)). +* Change: (For new installs) logs purge automatically after a month ([#71](https://github.com/soup-bowl/wp-simple-smtp/issues/71)). * Change: Quick config settings now contained within plugin ([#78](https://github.com/soup-bowl/wp-simple-smtp/issues/78)). * Change: Tightened permissions to the log viewer ([#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74)). * Fix: Incorrect capability type used by the log viewer. Thanks to [Benoît Chantre](https://github.com/benoitchantre) [#74](https://github.com/soup-bowl/wp-simple-smtp/issues/74). From 294638e3b5c7cf8ec2618721dea737ac88e5ebb0 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 23 Jan 2022 15:29:54 +0000 Subject: [PATCH 25/26] New version is 1.3 not 1.2.4. --- readme.txt | 4 ++-- wp-simple-smtp.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index f779e56..546653e 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: mail,email,smtp,dispatch,sender Requires at least: 4.9 Tested up to: 5.9 Requires PHP: 7.0 -Stable tag: 1.2.4 +Stable tag: 1.3 License: MIT Adds a simple mail configuration panel into your WordPress installation. Supports logging and config variables. @@ -90,7 +90,7 @@ To help diagnose disabled input boxes, when the WordPress site is in [debugging Yes! [Please see our GitHub repository here](https://github.com/soup-bowl/wp-simple-smtp) for writing issues and/or making pull requests. == Changelog == -= 1.2.4 = += 1.3 = * Added: Read logged emails via WP-CLI. * Added: Status message from testing emails ([#81](https://github.com/soup-bowl/wp-simple-smtp/issues/81)). * Change: Uninstalling the plugin will remove the lingering logs ([#70](https://github.com/soup-bowl/wp-simple-smtp/issues/70)). diff --git a/wp-simple-smtp.php b/wp-simple-smtp.php index dfef000..20823fc 100644 --- a/wp-simple-smtp.php +++ b/wp-simple-smtp.php @@ -10,7 +10,7 @@ * Plugin Name: Simple SMTP * Description: Adds mail configuration to WordPress in a simple, standardised plugin. * Plugin URI: https://www.soupbowl.io/wp-plugins - * Version: edge + * Version: 1.3 * Author: soup-bowl * Author URI: https://www.soupbowl.io * License: MIT From 936a237c1ae1c00f5075a2a4e595f48c1f331d84 Mon Sep 17 00:00:00 2001 From: soup-bowl Date: Sun, 23 Jan 2022 15:34:29 +0000 Subject: [PATCH 26/26] Log elaboration. --- readme.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index 546653e..20582cb 100644 --- a/readme.txt +++ b/readme.txt @@ -7,11 +7,13 @@ Requires PHP: 7.0 Stable tag: 1.3 License: MIT -Adds a simple mail configuration panel into your WordPress installation. Supports logging and config variables. +Adds a simple mail configuration panel into your WordPress installation. Supports temporary logging and config variables. == Description == Adds a simple, no-fuss SMTP settings to your WordPress installation that lets you define custom settings, which is especially useful for hosts with no control over the php `mail` functionality. +If logging is enabled, a new segment in the settings panel will show up with a 30-day overview of recent emails, and will automatically prune older logs. Please see the FAQ if you want a more permanent solution. + ## Environment and constant overriding (optional) This plugin will prefer environmental and constant-stored values over the plugin-saved equivalent settings, making it easier to use this plugin via deployment. @@ -52,8 +54,8 @@ The over-ride hierachy is as follows, with top being the most important. * Multisite network settings. * Locally-configured settings. -= How do I stop the logs auto-prune? = -Register the following hook (typically in your theme functions.php) to disable the auto-pruning functionality: += How do I stop the logs from automatically purging? = +The logs by default will auto-prune to avoid keeping sensitive details in logs and contributing to database bloat. But if you wish to keep the logs more permanently, then register the following hook (typically in your theme functions.php) to disable the auto-pruning functionality: ``` add_filter( 'simple_smtp_disable_log_prune', '__return_true' );