@@ -1469,6 +1478,36 @@ class Settings_Page {
+
+
+ get_admin_url_for_scope( $scope, 'admin.php' );
+ ?>
+
+
+
@@ -2429,6 +2468,28 @@ class Settings_Page {
$mx_analysis = $this->analyze_mx_records( $sender_domain, $normalized_smtp_host );
}
+ // Read and validate a custom DKIM selector from the request.
+ $custom_selector_raw = filter_input( INPUT_GET, 'dkim_selector', FILTER_UNSAFE_RAW );
+ $custom_selector = ( is_string( $custom_selector_raw ) && preg_match( '/^[a-zA-Z0-9_\-]{1,63}$/', $custom_selector_raw ) )
+ ? sanitize_key( $custom_selector_raw )
+ : '';
+
+ // Build the list of MX hostnames for provider detection.
+ $mx_hosts = array();
+ foreach ( $mx_analysis['records'] as $mx_record ) {
+ $normalized = $this->normalize_hostname( $mx_record['display_target'] );
+ if ( '' !== $normalized ) {
+ $mx_hosts[] = $normalized;
+ }
+ }
+
+ // Determine which selectors to try.
+ if ( '' !== $custom_selector ) {
+ $dkim_selectors = array( $custom_selector );
+ } else {
+ $dkim_selectors = $this->get_known_dkim_selectors_for_mx( $mx_hosts );
+ }
+
ob_start();
if ( '' === $sender_domain ) :
@@ -2439,6 +2500,7 @@ class Settings_Page {
analyze_domain_authentication( $sender_domain, $normalized_smtp_host, $mx_analysis, $host_ips );
+ $dkim_result = $this->try_dkim_selectors( $sender_domain, $dkim_selectors );
if ( ! empty( $auth_analysis['errors'] ) ) :
?>
@@ -2490,24 +2552,44 @@ class Settings_Page {
-
+
-
+
@@ -3490,6 +3572,89 @@ class Settings_Page {
);
}
+
+ /**
+ * Handles the request to clear the stored SMTP password.
+ *
+ * Triggered by the "Clear password" form on the settings page.
+ * Works in both site and network scope.
+ *
+ * @since 2.2.1
+ *
+ * @return void
+ */
+ public function handle_clear_password(): void {
+ // Link uses GET (wp_nonce_url), so nonce arrives in INPUT_GET.
+ $nonce_raw = filter_input( INPUT_GET, '_wpnonce', FILTER_UNSAFE_RAW );
+ if ( ! is_string( $nonce_raw ) || ! wp_verify_nonce( wp_unslash( $nonce_raw ), 'robotstxt_smtp_clear_password' ) ) {
+ wp_die( esc_html__( 'The link you followed has expired.', 'robotstxt-smtp' ) );
+ }
+
+ $scope_raw = filter_input( INPUT_GET, 'robotstxt_smtp_scope', FILTER_UNSAFE_RAW );
+ $scope = ( is_string( $scope_raw ) && self::SCOPE_NETWORK === sanitize_key( wp_unslash( $scope_raw ) ) )
+ ? self::SCOPE_NETWORK
+ : self::SCOPE_SITE;
+
+ $this->ensure_capability( $scope );
+
+ if ( self::SCOPE_NETWORK === $scope ) {
+ $settings = get_site_option( self::NETWORK_OPTION_NAME, array() );
+ $settings = is_array( $settings ) ? $settings : array();
+ $settings['password'] = '';
+ // site options have no registered sanitize_callback, safe to update directly.
+ update_site_option( self::NETWORK_OPTION_NAME, $settings );
+ $page_url = network_admin_url( 'admin.php' );
+ $page_slug = self::NETWORK_PAGE_SLUG;
+ } else {
+ $settings = get_option( self::OPTION_NAME, array() );
+ $settings = is_array( $settings ) ? $settings : array();
+ $settings['password'] = '';
+ // Temporarily remove the registered sanitize_callback so that password=''
+ // is stored as-is. Without this, sanitize_options() treats an empty
+ // password as "keep the existing value" and the clear has no effect.
+ remove_filter( 'sanitize_option_' . self::OPTION_NAME, array( $this, 'sanitize_options' ) );
+ update_option( self::OPTION_NAME, $settings );
+ add_filter( 'sanitize_option_' . self::OPTION_NAME, array( $this, 'sanitize_options' ) );
+ $page_url = admin_url( 'admin.php' );
+ $page_slug = self::PAGE_SLUG;
+ }
+
+ wp_safe_redirect(
+ add_query_arg(
+ array(
+ 'page' => $page_slug,
+ 'robotstxt_smtp_pw_cleared' => '1',
+ ),
+ $page_url
+ )
+ );
+ exit;
+ }
+
+ /**
+ * Displays a success notice after the password has been cleared.
+ *
+ * @since 2.2.1
+ *
+ * @return void
+ */
+ public function display_clear_password_notice(): void {
+ $pw_cleared_raw = filter_input( INPUT_GET, 'robotstxt_smtp_pw_cleared', FILTER_UNSAFE_RAW );
+ if ( '1' !== $pw_cleared_raw ) {
+ return;
+ }
+
+ $screen = get_current_screen();
+ if ( null === $screen || false === strpos( $screen->id, 'robotstxt-smtp' ) ) {
+ return;
+ }
+ ?>
+
+ get_settings();
- $has_password = '' !== $settings['password'];
- $placeholder_msg = $has_password ? __( 'Leave empty to keep the current password.', 'robotstxt-smtp' ) : '';
+ $settings = $this->get_settings();
+ $has_password = '' !== $settings['password'];
+ $placeholder = $has_password
+ ? __( 'Leave empty to keep the current password.', 'robotstxt-smtp' )
+ : __( 'No password set.', 'robotstxt-smtp' );
+ $scope = $this->get_current_admin_scope();
?>
-
-
- get_settings_field_name( 'password' ) ); ?>"
+ type="password"
+ id="robotstxt_smtp_password"
+ class="regular-text"
+ value=""
+ autocomplete="new-password"
+ placeholder=""
+ />
+
+ 'robotstxt_smtp_clear_password',
+ 'robotstxt_smtp_scope' => $scope,
+ ),
+ admin_url( 'admin-post.php' )
+ ),
+ 'robotstxt_smtp_clear_password'
+ );
+ ?>
+
+
+
+
+
+
+
+ , record: string}
*/
- private function analyze_dkim_record( string $domain ): array {
+ private function analyze_dkim_record( string $domain, string $selector = 'default' ): array {
$result = array(
'found' => false,
'errors' => array(),
@@ -5302,7 +5519,7 @@ class Settings_Page {
return $result;
}
- $selector_domain = 'default._domainkey.' . $domain;
+ $selector_domain = $selector . '._domainkey.' . $domain;
$records = $this->safe_dns_lookup( $selector_domain, DNS_TXT, 2 );
if ( false === $records ) {
@@ -5329,6 +5546,83 @@ class Settings_Page {
return $result;
}
+ /**
+ * Returns an ordered list of DKIM selectors to try based on MX hostname patterns.
+ *
+ * @since 2.2.1
+ *
+ * @param array
$mx_hosts Lowercase MX hostnames.
+ * @return array Selectors to try in order, always ending with 'default'.
+ */
+ private function get_known_dkim_selectors_for_mx( array $mx_hosts ): array {
+ // Each entry: [regex, selectors]. First pattern match wins.
+ $patterns = array(
+ array( '/\.google\.com$/i', array( 'google', 'google2' ) ),
+ array( '/\.outlook\.com$/i', array( 'selector1', 'selector2' ) ),
+ array( '/\.mail\.protection\.outlook\.com$/i', array( 'selector1', 'selector2' ) ),
+ array( '/\.zoho\.com$/i', array( 'zoho', 'zmail' ) ),
+ array( '/\.protonmail\.ch$/i', array( 'protonmail', 'protonmail2', 'protonmail3' ) ),
+ array( '/\.icloud\.com$/i', array( 'sig1' ) ),
+ array( '/\.aruba\.it$/i', array( 'a1' ) ),
+ array( '/\.mcsv\.net$/i', array( 'k1', 'k2', 'k3' ) ),
+ );
+
+ foreach ( $mx_hosts as $host ) {
+ foreach ( $patterns as $entry ) {
+ if ( preg_match( $entry[0], $host ) ) {
+ $selectors = $entry[1];
+ $selectors[] = 'default';
+ return $selectors;
+ }
+ }
+ }
+
+ return array( 'default' );
+ }
+
+ /**
+ * Tries DKIM selectors in order and returns the first found record.
+ *
+ * @since 2.2.1
+ *
+ * @param string $domain Domain to check.
+ * @param array $selectors Selectors to try in order.
+ * @return array{found: bool, selector: string, record: string, errors: list, tried: list}
+ */
+ private function try_dkim_selectors( string $domain, array $selectors ): array {
+ $result = array(
+ 'found' => false,
+ 'selector' => '',
+ 'record' => '',
+ 'errors' => array(),
+ 'tried' => array(),
+ );
+
+ if ( ! function_exists( 'dns_get_record' ) ) {
+ $result['errors'][] = __( 'DNS lookups are not available because the DNS functions are disabled on this server.', 'robotstxt-smtp' );
+ return $result;
+ }
+
+ foreach ( $selectors as $selector ) {
+ $result['tried'][] = $selector;
+ $lookup = $this->analyze_dkim_record( $domain, $selector );
+
+ if ( ! empty( $lookup['errors'] ) ) {
+ $result['errors'] = $lookup['errors'];
+ return $result;
+ }
+
+ if ( true === $lookup['found'] ) {
+ $result['found'] = true;
+ $result['selector'] = $selector;
+ $result['record'] = $lookup['record'];
+ return $result;
+ }
+ }
+
+ return $result;
+ }
+
/**
* Looks up the DMARC policy for the sender domain.
*
diff --git a/readme.txt b/readme.txt
index b19dd1b..d6ef86e 100644
--- a/readme.txt
+++ b/readme.txt
@@ -3,9 +3,9 @@ Contributors: javiercasares
Tags: smtp, email, mail
Requires at least: 5.9
Tested up to: 7.1
-Stable tag: 2.2.1
+Stable tag: 2.2.2
Requires PHP: 8.0
-Version: 2.2.1
+Version: 2.2.2
License: GPL-3.0-or-later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -70,6 +70,29 @@ Yes. From the network dashboard you can decide whether the configuration is glob
== Changelog ==
+= 2.2.2 =
+
+_Release date: 2026-06-09_
+
+**Fixed**
+
+* Fixed From Email and Reply-To Email not clearing when submitted empty.
+* Fixed "Clear password" button having no effect due to `sanitize_option` callback re-applying the old password.
+* Fixed "Clear password" submitting to `options.php` instead of the correct handler (nested form issue).
+* Fixed DKIM "Try selector" button doing nothing (`wp_kses_post()` stripped the form elements).
+* Fixed Spamhaus ZEN reporting a false "Listed" result for `127.255.255.254` (open-resolver error code, not a real listing).
+
+**Added**
+
+* DKIM selector auto-detection from MX records (Google Workspace, Microsoft 365, Zoho, ProtonMail, iCloud, Aruba, Mailchimp).
+* "Try a specific selector" input in Tools → Authentication.
+* Password field placeholder now reflects whether a password is stored.
+
+**Compatibility**
+
+* WordPress: 5.9 - 7.1
+* PHP: 8.0 - 8.5
+
= 2.2.1 =
_Release date: 2026-06-09_
diff --git a/robotstxt-smtp.php b/robotstxt-smtp.php
index 5c3d388..a2490ae 100644
--- a/robotstxt-smtp.php
+++ b/robotstxt-smtp.php
@@ -3,7 +3,7 @@
* Plugin Name: SMTP (by ROBOTSTXT)
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp
* Description: Configure WordPress to send emails through SMTP with detailed controls.
- * Version: 2.2.1
+ * Version: 2.2.2
* Requires at least: 5.9
* Requires PHP: 8.0
* Network: true
@@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
}
if ( ! defined( 'ROBOTSTXT_SMTP_VERSION' ) ) {
- define( 'ROBOTSTXT_SMTP_VERSION', '2.2.1' );
+ define( 'ROBOTSTXT_SMTP_VERSION', '2.2.2' );
}
if ( ! defined( 'ROBOTSTXT_SMTP_FILE' ) ) {
diff --git a/update.json b/update.json
index 12e4232..8c586be 100644
--- a/update.json
+++ b/update.json
@@ -1,8 +1,8 @@
{
"name": "SMTP (by ROBOTSTXT)",
"slug": "robotstxt-smtp",
- "version": "2.2.1",
- "download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp/releases/download/2.2.1/robotstxt-smtp-2.2.1.zip",
+ "version": "2.2.2",
+ "download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp/releases/download/2.2.2/robotstxt-smtp-2.2.2.zip",
"requires": "5.9",
"requires_php": "8.0",
"tested": "7.1",
@@ -11,10 +11,10 @@
"author_profile": "https://www.robotstxt.es/",
"homepage": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp",
"description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.",
- "changelog": "2.2.1 - 2026-06-09 Fixed: Statistics chart not rendering due to script load-order issueFixed: Chart.js now bundled locally — no external CDN requests2.2.0 - 2026-06-09 Security: Fixed passwords with special characters being silently corrupted on saveSecurity: Fixed credentials no longer stored in transients after test emailSecurity: Fixed credential mask bug in test email panelFixed: DMARC tool now implements RFC 7489 §6.6.3 organizational domain fallbackFixed: Rate-limit enforcement now short-circuits wp_mail() immediatelyFixed: DKIM and DMARC DNS lookups use timeout-protected wrapperFixed: Rate-limit transients removed on uninstallCompatibility: WordPress minimum lowered to 5.9Compatibility: PHP minimum lowered to 8.02.1.0 - 2026-02-09 Added: Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)Added: Reset plugin data functionality with site-level and network-level supportAdded: Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)Added: Automatic password clearing when both host and username fields are empty to prevent orphaned credentialsChanged: Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabledChanged: Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin ",
+ "changelog": "2.2.2 - 2026-06-09 Fixed: From Email and Reply-To Email not clearing when submitted emptyFixed: Clear password button had no effect (sanitize_option callback re-applied old password)Fixed: Clear password link submitted to options.php (nested form issue)Fixed: DKIM Try Selector button did nothing (wp_kses_post stripped form elements)Fixed: Spamhaus ZEN false "Listed" result for 127.255.255.254 (open-resolver error code)Added: DKIM selector auto-detection from MX records (Google Workspace, Microsoft 365, Zoho, ProtonMail, iCloud, Aruba, Mailchimp)Added: "Try a specific selector" input in Tools — AuthenticationAdded: Password field placeholder is now context-aware2.2.1 - 2026-06-09 Fixed: Statistics chart not rendering due to script load-order issueFixed: Chart.js now bundled locally — no external CDN requests2.2.0 - 2026-06-09 Security: Fixed passwords with special characters being silently corrupted on saveSecurity: Fixed credentials no longer stored in transients after test emailSecurity: Fixed credential mask bug in test email panelFixed: DMARC tool now implements RFC 7489 §6.6.3 organizational domain fallbackFixed: Rate-limit enforcement now short-circuits wp_mail() immediatelyFixed: DKIM and DMARC DNS lookups use timeout-protected wrapperFixed: Rate-limit transients removed on uninstallCompatibility: WordPress minimum lowered to 5.9Compatibility: PHP minimum lowered to 8.02.1.0 - 2026-02-09 Added: Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)Added: Reset plugin data functionality with site-level and network-level supportAdded: Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)Added: Automatic password clearing when both host and username fields are empty to prevent orphaned credentialsChanged: Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabledChanged: Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin ",
"sections": {
"description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.",
- "changelog": "2.2.1 - 2026-06-09 Fixed: Statistics chart not rendering due to script load-order issueFixed: Chart.js now bundled locally — no external CDN requests2.2.0 - 2026-06-09 Security: Fixed passwords with special characters being silently corrupted on saveSecurity: Fixed credentials no longer stored in transients after test emailSecurity: Fixed credential mask bug in test email panelFixed: DMARC tool now implements RFC 7489 §6.6.3 organizational domain fallbackFixed: Rate-limit enforcement now short-circuits wp_mail() immediatelyFixed: DKIM and DMARC DNS lookups use timeout-protected wrapperFixed: Rate-limit transients removed on uninstallCompatibility: WordPress minimum lowered to 5.9Compatibility: PHP minimum lowered to 8.02.1.0 - 2026-02-09 Added: Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)Added: Reset plugin data functionality with site-level and network-level supportAdded: Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)Added: Automatic password clearing when both host and username fields are empty to prevent orphaned credentialsChanged: Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabledChanged: Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin "
+ "changelog": "2.2.2 - 2026-06-09 Fixed: From Email and Reply-To Email not clearing when submitted emptyFixed: Clear password button had no effect (sanitize_option callback re-applied old password)Fixed: Clear password link submitted to options.php (nested form issue)Fixed: DKIM Try Selector button did nothing (wp_kses_post stripped form elements)Fixed: Spamhaus ZEN false "Listed" result for 127.255.255.254 (open-resolver error code)Added: DKIM selector auto-detection from MX records (Google Workspace, Microsoft 365, Zoho, ProtonMail, iCloud, Aruba, Mailchimp)Added: "Try a specific selector" input in Tools — AuthenticationAdded: Password field placeholder is now context-aware2.2.1 - 2026-06-09 Fixed: Statistics chart not rendering due to script load-order issueFixed: Chart.js now bundled locally — no external CDN requests2.2.0 - 2026-06-09 Security: Fixed passwords with special characters being silently corrupted on saveSecurity: Fixed credentials no longer stored in transients after test emailSecurity: Fixed credential mask bug in test email panelFixed: DMARC tool now implements RFC 7489 §6.6.3 organizational domain fallbackFixed: Rate-limit enforcement now short-circuits wp_mail() immediatelyFixed: DKIM and DMARC DNS lookups use timeout-protected wrapperFixed: Rate-limit transients removed on uninstallCompatibility: WordPress minimum lowered to 5.9Compatibility: PHP minimum lowered to 8.02.1.0 - 2026-02-09 Added: Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)Added: Reset plugin data functionality with site-level and network-level supportAdded: Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)Added: Automatic password clearing when both host and username fields are empty to prevent orphaned credentialsChanged: Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabledChanged: Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin "
},
"banners": {
"low": "",