This commit is contained in:
Javier Casares 2026-06-09 12:50:30 +00:00
commit 48cef88d49
6 changed files with 407 additions and 41 deletions

View file

@ -3,6 +3,24 @@
All notable changes to SMTP (by ROBOTSTXT) are documented in this file. All notable changes to SMTP (by ROBOTSTXT) are documented in this file.
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [2.2.2] - 2026-06-09
### Fixed
* **From Email / Reply-To Email not clearing.** `sanitize_options()` treated an empty submitted value as "keep the current value". Added explicit `$clean['from_email'] = ''` / `$clean['reply_to_email'] = ''` in the `else` branch so blanking the field is persisted.
* **"Clear password" had no effect.** `update_option()` always runs the registered `sanitize_option_{name}` callback, which re-applies the old password when the submitted value is empty. Fixed by temporarily removing the filter before `update_option()` and re-adding it after.
* **"Clear password" submitted to `options.php`.** The button was rendered inside a `<form>` nested inside the settings form. Nested forms are invalid HTML; the browser submits the outer form instead. Replaced with a `wp_nonce_url()` GET link that submits independently.
* **DKIM "Try selector" button did nothing.** The `<form>` was inside the cached tool HTML rendered via `wp_kses_post()`, which strips `<form>`, `<input>`, and `<button>` tags. Moved the form to `render_tools_page()` as direct PHP output, never passing through kses.
* **Spamhaus ZEN false "Listed" result.** Response code `127.255.255.254` is a Spamhaus infrastructure error ("query via public/open DNS resolver"), not a blacklist hit. Spamhaus dropped support for public-resolver queries in 2022. The plugin now detects `127.255.255.254` (open resolver) and `127.255.255.255` (rate limit exceeded) before setting `listed = true`, and shows an informational error with a link to the provider's web lookup tool.
### Added
* **DKIM selector auto-detection from MX records.** The authentication tool now checks the domain's MX records against known provider patterns and tries their well-known selectors before falling back to `default`. Providers covered: Google Workspace (`google`, `google2`), Microsoft 365 (`selector1`, `selector2`), Zoho (`zoho`, `zmail`), ProtonMail (`protonmail`, `protonmail2`, `protonmail3`), Apple iCloud (`sig1`), Aruba (`a1`), Mailchimp (`k1`, `k2`, `k3`).
* **"Try a specific selector" form** in Tools → Authentication. A GET form rendered outside `wp_kses_post()` allows overriding the auto-detected selector. The chosen selector is preserved in the "Run checks again" URL.
* **Password field placeholder is now context-aware.** Shows `No password set.` when no password is stored, and `Leave empty to keep the current password.` when one exists — no ambiguity for screen readers or keyboard-only users.
---
## [2.2.1] - 2026-06-09 ## [2.2.1] - 2026-06-09
### Fixed ### Fixed

View file

@ -1,5 +1,36 @@
== Changelog == == Changelog ==
= 2.2.2 =
_Release date: 2026-06-09_
**Fixed**
* Fixed From Email and Reply-To Email fields not clearing when submitted empty. `sanitize_options()` now explicitly saves `''` when the field is blank, instead of silently retaining the previous value.
* Fixed "Clear password" button having no effect. The registered `sanitize_option` callback was re-applying the old encrypted password when the submitted value was empty. Fixed by temporarily removing the filter before the direct `update_option()` call.
* Fixed "Clear password" button submitting to `options.php` instead of the intended handler. A nested `<form>` inside the settings form is invalid HTML; replaced with a `wp_nonce_url()` link (GET request).
* Fixed DKIM selector form ("Try selector" button) doing nothing. The form was inside the cached tool HTML rendered via `wp_kses_post()`, which strips all form elements. Moved the form to `render_tools_page()` where it is output as direct PHP, never passing through `kses`.
* Fixed Spamhaus ZEN reporting a false "Listed" result. Response code `127.255.255.254` means the DNS query arrived via a public resolver (Cloudflare, Google DNS, etc.) — not that the IP is blocked. Spamhaus stopped supporting public-resolver queries in 2022. The plugin now detects this code (and `127.255.255.255` for rate-limit exceeded) and shows an informational error pointing to the Spamhaus web lookup tool instead.
**Added**
* DKIM selector auto-detection from MX records. When running the SPF/DKIM/DMARC tool, the plugin detects the email provider from MX host patterns and tries the provider's known selectors in order before falling back to `default`. Supported providers: Google Workspace, Microsoft 365, Zoho, ProtonMail, Apple iCloud, Aruba, Mailchimp.
* "Try a specific selector" input in the Tools → Authentication panel. Allows overriding the auto-detected selector without JavaScript; the selector is preserved in the "Run checks again" URL.
* Password field placeholder is now context-aware: shows "No password set." when no password is stored, and "Leave empty to keep the current password." when one exists.
**Compatibility**
* WordPress: 5.9 - 7.1
* PHP: 8.0 - 8.5
**Tests**
* PHP Coding Standards: squizlabs/php_codesniffer 3.x, wp-coding-standards/wpcs 3.x
* WordPress Coding Standards: WordPress-Core, WordPress-Docs, WordPress-Extra
* PHPStan: level 9, szepeviktor/phpstan-wordpress 2.x
* PHPCompatibility: phpcompatibility/php-compatibility 10.x (PHP 8.0-8.5)
* WP Compatibility: johnbillion/wp-compat (WP 5.9+)
= 2.2.1 = = 2.2.1 =
_Release date: 2026-06-09_ _Release date: 2026-06-09_

View file

@ -301,6 +301,9 @@ class Settings_Page {
add_action( 'admin_post_robotstxt_smtp_save_network_settings', array( $this, 'handle_save_network_settings' ) ); add_action( 'admin_post_robotstxt_smtp_save_network_settings', array( $this, 'handle_save_network_settings' ) );
add_action( 'admin_post_robotstxt_smtp_reset_data', array( $this, 'handle_reset_data' ) ); add_action( 'admin_post_robotstxt_smtp_reset_data', array( $this, 'handle_reset_data' ) );
add_action( 'admin_post_robotstxt_smtp_reset_data_network', array( $this, 'handle_reset_data_network' ) ); add_action( 'admin_post_robotstxt_smtp_reset_data_network', array( $this, 'handle_reset_data_network' ) );
add_action( 'admin_post_robotstxt_smtp_clear_password', array( $this, 'handle_clear_password' ) );
add_action( 'admin_notices', array( $this, 'display_clear_password_notice' ) );
add_action( 'network_admin_notices', array( $this, 'display_clear_password_notice' ) );
add_action( 'admin_notices', array( $this, 'display_test_email_notice' ) ); add_action( 'admin_notices', array( $this, 'display_test_email_notice' ) );
add_action( 'network_admin_notices', array( $this, 'display_test_email_notice' ) ); add_action( 'network_admin_notices', array( $this, 'display_test_email_notice' ) );
add_action( 'admin_notices', array( $this, 'display_reset_data_notice' ) ); add_action( 'admin_notices', array( $this, 'display_reset_data_notice' ) );
@ -1388,6 +1391,11 @@ class Settings_Page {
} }
} }
$dkim_selector_raw = filter_input( INPUT_GET, 'dkim_selector', FILTER_UNSAFE_RAW );
$dkim_selector = ( is_string( $dkim_selector_raw ) && preg_match( '/^[a-zA-Z0-9_\-]{1,63}$/', $dkim_selector_raw ) )
? sanitize_key( $dkim_selector_raw )
: '';
$tools = array( $tools = array(
'mx' => array( 'mx' => array(
'title' => esc_html__( 'Automatic MX Lookup', 'robotstxt-smtp' ), 'title' => esc_html__( 'Automatic MX Lookup', 'robotstxt-smtp' ),
@ -1430,16 +1438,17 @@ class Settings_Page {
$result = $this->get_tool_result_for_display( $scope, $tool_key, $tool_definition['callback'], $run_now ); $result = $this->get_tool_result_for_display( $scope, $tool_key, $tool_definition['callback'], $run_now );
$has_result = null !== $result; $has_result = null !== $result;
$refresh_url = add_query_arg( $refresh_args = array(
array( 'page' => self::TOOLS_PAGE_SLUG,
'page' => self::TOOLS_PAGE_SLUG, 'robotstxt_smtp_tool' => $tool_key,
'robotstxt_smtp_tool' => $tool_key, 'robotstxt_smtp_refresh' => '1',
'robotstxt_smtp_refresh' => '1',
),
$base_url
); );
if ( 'authentication' === $tool_key && '' !== $dkim_selector ) {
$refresh_args['dkim_selector'] = $dkim_selector;
}
$refresh_url = add_query_arg( $refresh_args, $base_url );
$refresh_url = wp_nonce_url( $refresh_url, 'robotstxt_smtp_refresh_tool_' . $tool_key ); $refresh_url = wp_nonce_url( $refresh_url, 'robotstxt_smtp_refresh_tool_' . $tool_key );
?> ?>
<div class="card robotstxt-smtp-tool-card" data-tool="<?php echo esc_attr( $tool_key ); ?>"> <div class="card robotstxt-smtp-tool-card" data-tool="<?php echo esc_attr( $tool_key ); ?>">
<h2><?php echo esc_html( $tool_definition['title'] ); ?></h2> <h2><?php echo esc_html( $tool_definition['title'] ); ?></h2>
<p><?php echo esc_html( $tool_definition['description'] ); ?></p> <p><?php echo esc_html( $tool_definition['description'] ); ?></p>
@ -1469,6 +1478,36 @@ class Settings_Page {
<div class="robotstxt-smtp-tool-result"> <div class="robotstxt-smtp-tool-result">
<?php echo isset( $result['html'] ) && is_string( $result['html'] ) ? wp_kses_post( $result['html'] ) : ''; ?> <?php echo isset( $result['html'] ) && is_string( $result['html'] ) ? wp_kses_post( $result['html'] ) : ''; ?>
</div> </div>
<?php if ( 'authentication' === $tool_key ) : ?>
<?php
// Render DKIM selector form here — outside wp_kses_post() which strips form elements.
$dkim_form_url = $this->get_admin_url_for_scope( $scope, 'admin.php' );
?>
<form method="get" action="<?php echo esc_url( $dkim_form_url ); ?>" style="margin-top: 12px; padding-top: 12px; border-top: 1px solid #dcdcde;">
<input type="hidden" name="page" value="<?php echo esc_attr( self::SCOPE_NETWORK === $scope ? self::NETWORK_MENU_SLUG . '-tools' : self::TOOLS_PAGE_SLUG ); ?>" />
<input type="hidden" name="robotstxt_smtp_tool" value="authentication" />
<input type="hidden" name="robotstxt_smtp_refresh" value="1" />
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( 'robotstxt_smtp_refresh_tool_authentication' ) ); ?>" />
<label for="robotstxt_smtp_dkim_selector_input" style="display:inline-block; margin-right:6px;">
<?php esc_html_e( 'Try a specific selector:', 'robotstxt-smtp' ); ?>
</label>
<input
type="text"
name="dkim_selector"
id="robotstxt_smtp_dkim_selector_input"
value="<?php echo esc_attr( $dkim_selector ); ?>"
placeholder="<?php esc_attr_e( 'e.g. google, selector1, mail', 'robotstxt-smtp' ); ?>"
maxlength="63"
pattern="[a-zA-Z0-9_\-]+"
style="width: 200px;"
/>
<button type="submit" class="button button-secondary" style="margin-left: 4px;">
<?php esc_html_e( 'Try selector', 'robotstxt-smtp' ); ?>
</button>
</form>
<?php endif; ?>
<?php else : ?> <?php else : ?>
<p class="robotstxt-smtp-tool-empty"> <p class="robotstxt-smtp-tool-empty">
<?php esc_html_e( 'There are no results yet. Click the button below to run this check.', 'robotstxt-smtp' ); ?> <?php esc_html_e( 'There are no results yet. Click the button below to run this check.', 'robotstxt-smtp' ); ?>
@ -2429,6 +2468,28 @@ class Settings_Page {
$mx_analysis = $this->analyze_mx_records( $sender_domain, $normalized_smtp_host ); $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(); ob_start();
if ( '' === $sender_domain ) : if ( '' === $sender_domain ) :
@ -2439,6 +2500,7 @@ class Settings_Page {
<?php <?php
else : else :
$auth_analysis = $this->analyze_domain_authentication( $sender_domain, $normalized_smtp_host, $mx_analysis, $host_ips ); $auth_analysis = $this->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'] ) ) : if ( ! empty( $auth_analysis['errors'] ) ) :
?> ?>
@ -2490,24 +2552,44 @@ class Settings_Page {
<h3><?php esc_html_e( 'DKIM', 'robotstxt-smtp' ); ?></h3> <h3><?php esc_html_e( 'DKIM', 'robotstxt-smtp' ); ?></h3>
<?php if ( ! empty( $auth_analysis['dkim']['errors'] ) ) : ?> <?php if ( ! empty( $dkim_result['errors'] ) ) : ?>
<div class="notice notice-error inline"> <div class="notice notice-error inline">
<ul> <ul>
<?php foreach ( $auth_analysis['dkim']['errors'] as $error ) : ?> <?php foreach ( $dkim_result['errors'] as $error ) : ?>
<li><?php echo esc_html( $error ); ?></li> <li><?php echo esc_html( $error ); ?></li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
</div> </div>
<?php elseif ( true === $auth_analysis['dkim']['found'] ) : ?> <?php elseif ( true === $dkim_result['found'] ) : ?>
<div class="notice notice-success inline"> <div class="notice notice-success inline">
<p><?php esc_html_e( 'A DKIM record was found for the default selector.', 'robotstxt-smtp' ); ?></p> <p>
<?php if ( '' !== $auth_analysis['dkim']['record'] ) : ?> <?php
<p><code><?php echo esc_html( $auth_analysis['dkim']['record'] ); ?></code></p> printf(
/* translators: %s: DKIM selector name that was matched. */
esc_html__( 'A DKIM record was found for the selector "%s".', 'robotstxt-smtp' ),
esc_html( $dkim_result['selector'] )
);
?>
</p>
<?php if ( '' !== $dkim_result['record'] ) : ?>
<p><code><?php echo esc_html( $dkim_result['record'] ); ?></code></p>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php else : ?> <?php else : ?>
<div class="notice notice-warning inline"> <div class="notice notice-warning inline">
<p><?php esc_html_e( 'No DKIM record was found for the default selector. Confirm the selector provided by your email service and publish the corresponding TXT record.', 'robotstxt-smtp' ); ?></p> <?php if ( '' === $custom_selector && count( $dkim_result['tried'] ) > 0 ) : ?>
<p>
<?php
printf(
/* translators: %s: Comma-separated list of DKIM selectors that were tried. */
esc_html__( 'No DKIM record was found after trying the following selectors: %s. Enter the selector provided by your email service below and try again.', 'robotstxt-smtp' ),
esc_html( implode( ', ', $dkim_result['tried'] ) )
);
?>
</p>
<?php else : ?>
<p><?php esc_html_e( 'No DKIM record was found for the specified selector. Confirm the selector provided by your email service and publish the corresponding TXT record.', 'robotstxt-smtp' ); ?></p>
<?php endif; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
@ -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;
}
?>
<div class="notice notice-success is-dismissible">
<p><?php esc_html_e( 'The SMTP password has been cleared.', 'robotstxt-smtp' ); ?></p>
</div>
<?php
}
/** /**
* Handles the request to clear all stored logs. * Handles the request to clear all stored logs.
* *
@ -3752,21 +3917,43 @@ class Settings_Page {
* @return void * @return void
*/ */
public function render_password_field(): void { public function render_password_field(): void {
$settings = $this->get_settings(); $settings = $this->get_settings();
$has_password = '' !== $settings['password']; $has_password = '' !== $settings['password'];
$placeholder_msg = $has_password ? __( 'Leave empty to keep the current password.', 'robotstxt-smtp' ) : ''; $placeholder = $has_password
? __( 'Leave empty to keep the current password.', 'robotstxt-smtp' )
: __( 'No password set.', 'robotstxt-smtp' );
$scope = $this->get_current_admin_scope();
?> ?>
<input <input
name="<?php echo esc_attr( $this->get_settings_field_name( 'password' ) ); ?>" name="<?php echo esc_attr( $this->get_settings_field_name( 'password' ) ); ?>"
type="password" type="password"
id="robotstxt_smtp_password" id="robotstxt_smtp_password"
class="regular-text" class="regular-text"
value="" value=""
autocomplete="new-password" autocomplete="new-password"
placeholder="<?php echo esc_attr( $placeholder_msg ); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>"
/> />
<p class="description"><?php esc_html_e( 'Enter the password or app-specific password for the SMTP user. Leave empty to retain the existing value.', 'robotstxt-smtp' ); ?></p> <?php if ( $has_password ) : ?>
<?php <?php
$clear_url = wp_nonce_url(
add_query_arg(
array(
'action' => 'robotstxt_smtp_clear_password',
'robotstxt_smtp_scope' => $scope,
),
admin_url( 'admin-post.php' )
),
'robotstxt_smtp_clear_password'
);
?>
<a href="<?php echo esc_url( $clear_url ); ?>" class="button button-secondary" style="margin-left: 6px;">
<?php esc_html_e( 'Clear password', 'robotstxt-smtp' ); ?>
</a>
<?php endif; ?>
<p class="description">
<?php esc_html_e( 'Enter the password or app-specific password for the SMTP user. Leave empty to retain the existing value.', 'robotstxt-smtp' ); ?>
</p>
<?php
} }
/** /**
@ -4122,6 +4309,8 @@ class Settings_Page {
'invalid_from_email', 'invalid_from_email',
__( 'The "From Email" address is not valid. Please provide a valid email address.', 'robotstxt-smtp' ) __( 'The "From Email" address is not valid. Please provide a valid email address.', 'robotstxt-smtp' )
); );
} else {
$clean['from_email'] = '';
} }
} }
@ -4139,6 +4328,8 @@ class Settings_Page {
'invalid_reply_to_email', 'invalid_reply_to_email',
__( 'The "Reply-To Email" address is not valid. Please provide a valid email address.', 'robotstxt-smtp' ) __( 'The "Reply-To Email" address is not valid. Please provide a valid email address.', 'robotstxt-smtp' )
); );
} else {
$clean['reply_to_email'] = '';
} }
} }
@ -4826,6 +5017,29 @@ class Settings_Page {
return $result; return $result;
} }
// Check for DNSBL infrastructure error codes returned in the 127.255.0.0/16 range.
// These are not real blacklist hits — they are error responses from the DNSBL provider:
// 127.255.255.254 — query was made via a public/open DNS resolver (e.g. Cloudflare, Google).
// Spamhaus and others block public-resolver queries since 2022.
// 127.255.255.255 — excessive querying from this resolver.
// Treat both as non-listed with an informational error message.
foreach ( $a_records as $record ) {
$rec_ip = isset( $record['ip'] ) && is_string( $record['ip'] ) ? $record['ip'] : '';
if ( '127.255.255.254' === $rec_ip ) {
$removal_url = $provider['removal_url'] ?? '';
$result['error'] = sprintf(
/* translators: %s: URL to the provider's web lookup tool. */
__( 'This DNSBL no longer accepts queries from public DNS resolvers. Use the provider\'s web tool to check manually: %s', 'robotstxt-smtp' ),
$removal_url
);
return $result;
}
if ( '127.255.255.255' === $rec_ip ) {
$result['error'] = __( 'The DNSBL rate limit was exceeded from the server\'s DNS resolver. Try again later or use the provider\'s web lookup tool.', 'robotstxt-smtp' );
return $result;
}
}
$result['listed'] = true; $result['listed'] = true;
foreach ( $a_records as $record ) { foreach ( $a_records as $record ) {
@ -5283,13 +5497,16 @@ class Settings_Page {
} }
/** /**
* Looks up a DKIM record using the default selector. * Looks up a DKIM record for the specified selector.
* *
* @param string $domain Domain to inspect. * @since 2.2.1
*
* @param string $domain Domain to inspect.
* @param string $selector DKIM selector to query. Defaults to 'default'.
* *
* @return array{found: bool, errors: list<string>, record: string} * @return array{found: bool, errors: list<string>, record: string}
*/ */
private function analyze_dkim_record( string $domain ): array { private function analyze_dkim_record( string $domain, string $selector = 'default' ): array {
$result = array( $result = array(
'found' => false, 'found' => false,
'errors' => array(), 'errors' => array(),
@ -5302,7 +5519,7 @@ class Settings_Page {
return $result; return $result;
} }
$selector_domain = 'default._domainkey.' . $domain; $selector_domain = $selector . '._domainkey.' . $domain;
$records = $this->safe_dns_lookup( $selector_domain, DNS_TXT, 2 ); $records = $this->safe_dns_lookup( $selector_domain, DNS_TXT, 2 );
if ( false === $records ) { if ( false === $records ) {
@ -5329,6 +5546,83 @@ class Settings_Page {
return $result; return $result;
} }
/**
* Returns an ordered list of DKIM selectors to try based on MX hostname patterns.
*
* @since 2.2.1
*
* @param array<int, string> $mx_hosts Lowercase MX hostnames.
* @return array<int, string> 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<int, string> $selectors Selectors to try in order.
* @return array{found: bool, selector: string, record: string, errors: list<string>, tried: list<string>}
*/
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. * Looks up the DMARC policy for the sender domain.
* *

View file

@ -3,9 +3,9 @@ Contributors: javiercasares
Tags: smtp, email, mail Tags: smtp, email, mail
Requires at least: 5.9 Requires at least: 5.9
Tested up to: 7.1 Tested up to: 7.1
Stable tag: 2.2.1 Stable tag: 2.2.2
Requires PHP: 8.0 Requires PHP: 8.0
Version: 2.2.1 Version: 2.2.2
License: GPL-3.0-or-later License: GPL-3.0-or-later
License URI: https://www.gnu.org/licenses/gpl-3.0.html 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 == == 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 = = 2.2.1 =
_Release date: 2026-06-09_ _Release date: 2026-06-09_

View file

@ -3,7 +3,7 @@
* Plugin Name: SMTP (by ROBOTSTXT) * Plugin Name: SMTP (by ROBOTSTXT)
* Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp * Plugin URI: https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp
* Description: Configure WordPress to send emails through SMTP with detailed controls. * 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 at least: 5.9
* Requires PHP: 8.0 * Requires PHP: 8.0
* Network: true * Network: true
@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
if ( ! defined( 'ROBOTSTXT_SMTP_VERSION' ) ) { if ( ! defined( 'ROBOTSTXT_SMTP_VERSION' ) ) {
define( 'ROBOTSTXT_SMTP_VERSION', '2.2.1' ); define( 'ROBOTSTXT_SMTP_VERSION', '2.2.2' );
} }
if ( ! defined( 'ROBOTSTXT_SMTP_FILE' ) ) { if ( ! defined( 'ROBOTSTXT_SMTP_FILE' ) ) {

View file

@ -1,8 +1,8 @@
{ {
"name": "SMTP (by ROBOTSTXT)", "name": "SMTP (by ROBOTSTXT)",
"slug": "robotstxt-smtp", "slug": "robotstxt-smtp",
"version": "2.2.1", "version": "2.2.2",
"download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp/releases/download/2.2.1/robotstxt-smtp-2.2.1.zip", "download_url": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp/releases/download/2.2.2/robotstxt-smtp-2.2.2.zip",
"requires": "5.9", "requires": "5.9",
"requires_php": "8.0", "requires_php": "8.0",
"tested": "7.1", "tested": "7.1",
@ -11,10 +11,10 @@
"author_profile": "https://www.robotstxt.es/", "author_profile": "https://www.robotstxt.es/",
"homepage": "https://git.robotstxt.es/ROBOTSTXT/robotstxt-smtp", "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.", "description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.",
"changelog": "<h3>2.2.1 - 2026-06-09</h3><ul><li><strong>Fixed:</strong> Statistics chart not rendering due to script load-order issue</li><li><strong>Fixed:</strong> Chart.js now bundled locally — no external CDN requests</li></ul><h3>2.2.0 - 2026-06-09</h3><ul><li><strong>Security:</strong> Fixed passwords with special characters being silently corrupted on save</li><li><strong>Security:</strong> Fixed credentials no longer stored in transients after test email</li><li><strong>Security:</strong> Fixed credential mask bug in test email panel</li><li><strong>Fixed:</strong> DMARC tool now implements RFC 7489 §6.6.3 organizational domain fallback</li><li><strong>Fixed:</strong> Rate-limit enforcement now short-circuits wp_mail() immediately</li><li><strong>Fixed:</strong> DKIM and DMARC DNS lookups use timeout-protected wrapper</li><li><strong>Fixed:</strong> Rate-limit transients removed on uninstall</li><li><strong>Compatibility:</strong> WordPress minimum lowered to 5.9</li><li><strong>Compatibility:</strong> PHP minimum lowered to 8.0</li></ul><h3>2.1.0 - 2026-02-09</h3><ul><li><strong>Added:</strong> Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)</li><li><strong>Added:</strong> Reset plugin data functionality with site-level and network-level support</li><li><strong>Added:</strong> Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)</li><li><strong>Added:</strong> Automatic password clearing when both host and username fields are empty to prevent orphaned credentials</li><li><strong>Changed:</strong> Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabled</li><li><strong>Changed:</strong> Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin</li></ul>", "changelog": "<h3>2.2.2 - 2026-06-09</h3><ul><li><strong>Fixed:</strong> From Email and Reply-To Email not clearing when submitted empty</li><li><strong>Fixed:</strong> Clear password button had no effect (sanitize_option callback re-applied old password)</li><li><strong>Fixed:</strong> Clear password link submitted to options.php (nested form issue)</li><li><strong>Fixed:</strong> DKIM Try Selector button did nothing (wp_kses_post stripped form elements)</li><li><strong>Fixed:</strong> Spamhaus ZEN false &quot;Listed&quot; result for 127.255.255.254 (open-resolver error code)</li><li><strong>Added:</strong> DKIM selector auto-detection from MX records (Google Workspace, Microsoft 365, Zoho, ProtonMail, iCloud, Aruba, Mailchimp)</li><li><strong>Added:</strong> &quot;Try a specific selector&quot; input in Tools — Authentication</li><li><strong>Added:</strong> Password field placeholder is now context-aware</li></ul><h3>2.2.1 - 2026-06-09</h3><ul><li><strong>Fixed:</strong> Statistics chart not rendering due to script load-order issue</li><li><strong>Fixed:</strong> Chart.js now bundled locally — no external CDN requests</li></ul><h3>2.2.0 - 2026-06-09</h3><ul><li><strong>Security:</strong> Fixed passwords with special characters being silently corrupted on save</li><li><strong>Security:</strong> Fixed credentials no longer stored in transients after test email</li><li><strong>Security:</strong> Fixed credential mask bug in test email panel</li><li><strong>Fixed:</strong> DMARC tool now implements RFC 7489 §6.6.3 organizational domain fallback</li><li><strong>Fixed:</strong> Rate-limit enforcement now short-circuits wp_mail() immediately</li><li><strong>Fixed:</strong> DKIM and DMARC DNS lookups use timeout-protected wrapper</li><li><strong>Fixed:</strong> Rate-limit transients removed on uninstall</li><li><strong>Compatibility:</strong> WordPress minimum lowered to 5.9</li><li><strong>Compatibility:</strong> PHP minimum lowered to 8.0</li></ul><h3>2.1.0 - 2026-02-09</h3><ul><li><strong>Added:</strong> Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)</li><li><strong>Added:</strong> Reset plugin data functionality with site-level and network-level support</li><li><strong>Added:</strong> Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)</li><li><strong>Added:</strong> Automatic password clearing when both host and username fields are empty to prevent orphaned credentials</li><li><strong>Changed:</strong> Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabled</li><li><strong>Changed:</strong> Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin</li></ul>",
"sections": { "sections": {
"description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.", "description": "Configure WordPress to send emails through SMTP with detailed controls. Supports multiple SMTP providers, logging, diagnostics, and network/site-level configuration.",
"changelog": "<h3>2.2.1 - 2026-06-09</h3><ul><li><strong>Fixed:</strong> Statistics chart not rendering due to script load-order issue</li><li><strong>Fixed:</strong> Chart.js now bundled locally — no external CDN requests</li></ul><h3>2.2.0 - 2026-06-09</h3><ul><li><strong>Security:</strong> Fixed passwords with special characters being silently corrupted on save</li><li><strong>Security:</strong> Fixed credentials no longer stored in transients after test email</li><li><strong>Security:</strong> Fixed credential mask bug in test email panel</li><li><strong>Fixed:</strong> DMARC tool now implements RFC 7489 §6.6.3 organizational domain fallback</li><li><strong>Fixed:</strong> Rate-limit enforcement now short-circuits wp_mail() immediately</li><li><strong>Fixed:</strong> DKIM and DMARC DNS lookups use timeout-protected wrapper</li><li><strong>Fixed:</strong> Rate-limit transients removed on uninstall</li><li><strong>Compatibility:</strong> WordPress minimum lowered to 5.9</li><li><strong>Compatibility:</strong> PHP minimum lowered to 8.0</li></ul><h3>2.1.0 - 2026-02-09</h3><ul><li><strong>Added:</strong> Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)</li><li><strong>Added:</strong> Reset plugin data functionality with site-level and network-level support</li><li><strong>Added:</strong> Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)</li><li><strong>Added:</strong> Automatic password clearing when both host and username fields are empty to prevent orphaned credentials</li><li><strong>Changed:</strong> Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabled</li><li><strong>Changed:</strong> Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin</li></ul>" "changelog": "<h3>2.2.2 - 2026-06-09</h3><ul><li><strong>Fixed:</strong> From Email and Reply-To Email not clearing when submitted empty</li><li><strong>Fixed:</strong> Clear password button had no effect (sanitize_option callback re-applied old password)</li><li><strong>Fixed:</strong> Clear password link submitted to options.php (nested form issue)</li><li><strong>Fixed:</strong> DKIM Try Selector button did nothing (wp_kses_post stripped form elements)</li><li><strong>Fixed:</strong> Spamhaus ZEN false &quot;Listed&quot; result for 127.255.255.254 (open-resolver error code)</li><li><strong>Added:</strong> DKIM selector auto-detection from MX records (Google Workspace, Microsoft 365, Zoho, ProtonMail, iCloud, Aruba, Mailchimp)</li><li><strong>Added:</strong> &quot;Try a specific selector&quot; input in Tools — Authentication</li><li><strong>Added:</strong> Password field placeholder is now context-aware</li></ul><h3>2.2.1 - 2026-06-09</h3><ul><li><strong>Fixed:</strong> Statistics chart not rendering due to script load-order issue</li><li><strong>Fixed:</strong> Chart.js now bundled locally — no external CDN requests</li></ul><h3>2.2.0 - 2026-06-09</h3><ul><li><strong>Security:</strong> Fixed passwords with special characters being silently corrupted on save</li><li><strong>Security:</strong> Fixed credentials no longer stored in transients after test email</li><li><strong>Security:</strong> Fixed credential mask bug in test email panel</li><li><strong>Fixed:</strong> DMARC tool now implements RFC 7489 §6.6.3 organizational domain fallback</li><li><strong>Fixed:</strong> Rate-limit enforcement now short-circuits wp_mail() immediately</li><li><strong>Fixed:</strong> DKIM and DMARC DNS lookups use timeout-protected wrapper</li><li><strong>Fixed:</strong> Rate-limit transients removed on uninstall</li><li><strong>Compatibility:</strong> WordPress minimum lowered to 5.9</li><li><strong>Compatibility:</strong> PHP minimum lowered to 8.0</li></ul><h3>2.1.0 - 2026-02-09</h3><ul><li><strong>Added:</strong> Data management option to control whether plugin data is deleted on uninstall (disabled by default for data preservation)</li><li><strong>Added:</strong> Reset plugin data functionality with site-level and network-level support</li><li><strong>Added:</strong> Unified uninstall cleanup system that handles all add-on data (Amazon SES, Newsletter)</li><li><strong>Added:</strong> Automatic password clearing when both host and username fields are empty to prevent orphaned credentials</li><li><strong>Changed:</strong> Uninstall behavior now respects user preference: data is preserved by default unless explicitly enabled</li><li><strong>Changed:</strong> Add-on plugins (Amazon SES, Newsletter) no longer perform cleanup on uninstall - all cleanup is centralized in the core plugin</li></ul>"
}, },
"banners": { "banners": {
"low": "", "low": "",