This commit is contained in:
Javier Casares 2026-06-09 12:55:04 +00:00
commit 6269b77f13
11 changed files with 741 additions and 469 deletions

View file

@ -1210,6 +1210,15 @@ class Plugin {
}
}
// The parent plugin only updates reply_to_email when a valid address is submitted — it never
// clears the field. Explicitly clear it here when the user submits an empty value.
if ( array_key_exists( 'reply_to_email', $options ) ) {
$submitted_reply_to = is_string( $options['reply_to_email'] ) ? \sanitize_email( \trim( $options['reply_to_email'] ) ) : '';
if ( '' === $submitted_reply_to ) {
$clean['reply_to_email'] = '';
}
}
return $clean;
}
@ -1491,17 +1500,7 @@ class Plugin {
$message = \esc_html( (string) $message );
// Allow saving if the error is due to missing IAM permissions (not authorization to use SES itself).
// The credentials may still work for sending emails which requires different permissions.
if ( 'AccessDeniedException' === $aws_error_code || 'UnauthorizedException' === $aws_error_code ) {
if ( \strpos( $message, 'not authorized to perform: ses:GetAccount' ) !== false ) {
// Permission error for GetAccount API - credentials might still work for sending.
// Return null (success) but we could add a notice here if needed.
return null;
}
}
// For authentication errors (invalid credentials), prevent saving.
// Block only when credentials are definitively wrong (wrong access key or signature).
if ( in_array( $aws_error_code, array( 'InvalidClientTokenId', 'SignatureDoesNotMatch', 'InvalidAccessKeyId' ), true ) ) {
return new WP_Error(
'robotstxt_smtp_amazon_ses_invalid_credentials',
@ -1513,26 +1512,10 @@ class Plugin {
);
}
// For other AWS errors, show warning but allow saving.
return new WP_Error(
'robotstxt_smtp_amazon_ses_invalid_credentials',
\sprintf(
/* translators: %s: Error message from Amazon SES. */
\esc_html__( 'Could not verify Amazon SES credentials: %s', 'robotstxt-smtp-amazonses' ),
$message
)
);
// Any other AWS error (missing permission, wrong region, SES not enabled in region, etc.) —
// the credentials may still be valid for sending. Allow saving.
} catch ( Throwable $exception ) {
$message = \esc_html( $exception->getMessage() );
return new WP_Error(
'robotstxt_smtp_amazon_ses_unexpected_error',
\sprintf(
/* translators: %s: Error message describing the unexpected failure. */
\esc_html__( 'An unexpected error occurred while validating Amazon SES credentials: %s', 'robotstxt-smtp-amazonses' ),
$message
)
);
unset( $exception ); // Network error or timeout — cannot validate, allow saving.
}
return null;