Back in April, I published the relaunch of Tinio SMTP Mailer (v1.1.0). Since then, its real-world production footprint has remained essentially the same: the same set of my own production sites, without telemetry or external tracking metrics to report how many additional installations run the plugin.
Even so, between August and November 2026, Tinio SMTP Mailer received three releases (1.2.0, 1.3.0, and 1.4.0) focused on improving resilience, security, compatibility with modern environments, and usability.
The project preserves the exact philosophy it held since its relaunch: minimal dependencies, tight integration with native WordPress APIs, and all execution logic contained in a single PHP file (simple-smtp-mailer.php), under the TinioSmtpMailer namespace.
This was not just about bolting on new features. Much of the work involved revisiting earlier decisions, anticipating operational edge cases, and refining plugin behavior in scenarios that don’t always surface during initial development.
Here is the technical walkthrough of everything that changed since v1.1.0.
The Evolution Across Three Releases
Before diving into the details, here is the high-level roadmap:
- v1.2.0: Initial security hardening, cryptographically secure IV generation, and admin enhancements.
- v1.3.0: Migration to AES-256-GCM authenticated encryption, credential redaction in debug logs, and database schema versioning.
- v1.4.0: Automatic real-time SMTP failover, transport traceability, early schema upgrades, and an admin UI redesign.
Each release built upon the foundation of the previous one, evolving a relatively straightforward SMTP plugin into a resilient tool capable of recovering from failures and preserving configuration integrity.
1. Real-Time Automatic SMTP Failover (v1.4.0)
The most significant functional change in this cycle is the addition of a secondary SMTP server (Fallback SMTP Configuration).
The motivation is simple: relying on a single email provider introduces a single point of failure. If the primary SMTP server stops responding, encounters connectivity issues, or fails to complete delivery, WordPress can be left without an alternative mechanism.
To address this, I introduced a second SMTP server that can attempt to salvage message delivery whenever the primary transport fails.
Automatic Failover via TinioPHPMailer
Instead of replacing wp_mail() or implementing an independent mailing subsystem, the plugin hooks into WordPress’s native phpmailer_init to work directly on the PHPMailer instance used by the core system.
The solution extends PHPMailer\PHPMailer\PHPMailer with a lightweight subclass called TinioPHPMailer, which intercepts the send() method.
The execution flow is as follows:
- WordPress prepares the message using its standard mechanism.
TinioPHPMailerattempts delivery via the primary SMTP server.- If PHPMailer returns a failure status or throws an exception during sending, the recovery mechanism kicks in.
- The plugin resets the connection state using
reset_for_retry(), configures the secondary server, and retries delivery. - If the secondary server completes the operation, the email is logged as sent via Fallback.
The primary SMTP connection uses a 15-second timeout. This corresponds to PHPMailer’s internal Timeout parameter, not an absolute boundary for the overall execution time of the request.
It is worth noting that failover is not restricted solely to network connection timeouts: it also activates on other failures that prevent completing delivery through the primary transport.
A Consideration Regarding Retries
Failover enhances transport availability, but it does not provide an exactly-once delivery guarantee.
There is an edge case worth keeping in mind: the primary server might accept the message and complete processing, yet the network connection could drop before PHPMailer receives the final acknowledgment. If the plugin interprets this as a failed delivery, it will re-attempt delivery via the secondary server.
Under those circumstances, the recipient could receive duplicate emails.
This is an inherent limitation of retries whenever the outcome of an SMTP transaction remains indeterminate. The mechanism aims to recover from transport failures, not to enforce strict single-delivery semantics.
There are also configuration states that differ from in-flight failures: if the primary credentials cannot be decrypted, the workflow falls back to PHP mail() before configuring the fallback SMTP. Therefore, not all primary server configuration issues necessarily result in a retry against the secondary server.
Functional Failover Testing
During development, I conducted basic functional tests on this mechanism, verifying that when the primary server fails, the plugin falls back to the secondary server and completes delivery.
No operational issues were found during these tests. However, there are edge cases that warrant more exhaustive test coverage, particularly scenarios where the connection terminates abruptly after the primary server has accepted the payload.
Testing this scenario is crucial to evaluate plugin behavior under indeterminate outcomes and potential duplicate deliveries. It is a limitation worth documenting and keeping in mind, even when the mechanism functions smoothly under standard test conditions.
Traceability in the Email Log
The log table now includes a Transport column, featuring a visual badge that identifies which server handled each message:
Primary (host)Fallback (host)
When the secondary server successfully delivers an email that initially failed on the primary, the log entry preserves the original error details alongside the success status.
This allows administrators to quickly spot if an upstream provider is having intermittent issues, even if end users never notice because the message was rescued by the secondary server.
Selective Testing
The Send Email screen now includes a connection selector to test two distinct scenarios:
- Primary SMTP with automatic Fallback: Uses the primary server while retaining the automatic recovery mechanism.
- Fallback SMTP: Forces a direct test against the secondary server.
This makes it possible to validate both server configurations without having to artificially disrupt the primary server.
2. Security and Code Hardening (v1.2.0 – v1.3.0)
Much of the work between August and November focused on auditing credential handling, reducing sensitive data exposure, and strengthening admin panel access controls.
AES-256-GCM Authenticated Encryption with Transparent Migration
In v1.1.0, SMTP passwords were encrypted using AES-256-CBC.
While CBC encrypts data, it does not provide authentication or inherently guarantee that ciphertext has not been tampered with. To address this, the evolution rolled out in two phases:
- In v1.2.0, cryptographically secure IV generation was introduced for every encryption operation using
random_bytes(). - In v1.3.0, the plugin migrated to AES-256-GCM authenticated encryption (AEAD), dropping the previous fallback on
openssl_random_pseudo_bytes().
The implementation uses:
- 256-bit keys derived via SHA-256.
- A random IV generated with
random_bytes(). - Encryption via
openssl_encrypt()withaes-256-gcm. - A 16-byte authentication tag.
- Authenticity verification during decryption via
openssl_decrypt().
The storage format maintains the ciphertext, IV, and authentication tag separately, encoded in Base64.
The key advantage over CBC is that GCM detects tampering with ciphertext during the decryption process. If authentication fails, the operation is rejected as invalid.
The encryption key is derived from WordPress security constants (AUTH_KEY, SECURE_AUTH_KEY, and LOGGED_IN_KEY), combined with an internal plugin salt. This avoids storing a static encryption key directly in the database.
Automatic Migration from AES-256-CBC
Sites that already had passwords stored in the older format do not need to reconfigure them manually.
The migration process works as follows:
- The plugin detects that the stored password uses the legacy format (lacking a GCM authentication tag).
- It attempts decryption using AES-256-CBC.
- Upon successful decryption, it re-encrypts the password using AES-256-GCM.
- It saves the newly encrypted payload for subsequent operations.
This migration occurs transparently on the first read of the credential, requiring zero intervention from the administrator.
This upgrade was not just verified in theory; it was tested against existing installations, confirming that AES-256-CBC stored passwords were successfully recovered and upgraded to AES-256-GCM without requiring manual reconfiguration.
There is an important operational caveat: because the encryption key relies on WordPress security constants, changing salts in wp-config.php will prevent decrypting credentials that were encrypted with previous values. Salt rotations must be managed cautiously on sites with configured SMTP credentials.
Credential Redaction in Debug Logs
PHPMailer’s verbose debug output can expose sensitive credentials during the SMTP authentication handshake.
In v1.3.0, I implemented automated filtering to sanitize credentials and authentication tokens before routing SMTPDebug output to error_log().
This protection covers the following authentication mechanisms:
AUTH PLAINAUTH LOGINXOAUTH2
It also accounts for Base64-encoded credentials and corresponding SASL authentication flows.
The goal is to prevent temporary troubleshooting sessions from inadvertently leaking production secrets into server logs.
This filter matches known authentication patterns implemented in the code; it should not be considered an absolute guarantee that every possible secret appearing in an SMTP exchange will be removed.
Additionally, the admin panel now displays a dismissible warning banner whenever PHPMailer debug mode is left active. It is a simple safeguard, but it prevents temporary diagnostic configurations from lingering forgotten in production.
Access Control, CSRF, and Sanitization
I also used the intermediate versions to overhaul admin panel security controls.
Key improvements include:
Destructive Actions Restricted to POST
Log purging and table clearing operations were migrated from GET query links to dedicated POST forms and admin-post endpoints.
Every operation enforces:
- Strict HTTP method verification.
- Independent nonces via
check_admin_referer(). - Explicit capability checks via
current_user_can('manage_options').
Nonces protect against CSRF attacks, while capability checks verify whether the user actually holds the authority to perform the action. They are complementary controls, not substitutes for one another.
Defense-in-Depth and Whitelisting
Explicit manage_options capability checks were added across all admin renderers and action handlers.
Input validation was tightened using whitelists and strict allowable ranges for options such as:
portsecuredebuglog_limit
This avoids relying solely on data sanitization to dictate what configuration values are accepted.
Sanitization and Escaping
A full pass was conducted adhering to WordPress Coding Standards (WPCS), applying context-appropriate helper functions throughout:
wp_unslash()absint()wp_kses_post()esc_html__()esc_attr()
The goal is to maintain a strict separation between raw input, persisted settings, and rendered markup.
3. Database Stability, Hooks, and WordPress 7.0+ Compatibility (v1.2.0 – v1.4.0)
Beyond adding functional features, a large portion of maintenance focused on stabilizing plugin behavior across updates and integrating cleanly into the WordPress lifecycle.
WordPress Requirements and APIs
The minimum compatibility requirement was raised to WordPress 6.4+, with tests conducted against WordPress 7.0+, retaining PHP 8.1+ as the baseline and PHP 8.3+ as the recommended runtime.
Admin notices were standardized using wp_admin_notice(), and settings registration in register_setting() was updated to use the modern structured schema format of the WordPress Settings API.
These changes may not introduce visible UI features, but they ensure cleaner alignment with modern versions of the CMS.
Schema Versioning and MySQL 8.0+ Strict Mode
A common issue when updating a plugin with custom tables is that updated code may try to write data to columns that do not yet exist on upgraded sites.
To prevent this, v1.3.0 introduced schema versioning tracked via the tinio_smtp_db_version option.
Initially, schema updates were triggered on admin_init, but in v1.4.0 I moved maybe_upgrade_db() to the plugins_loaded hook, using dbDelta() and setting DB_VERSION = 1.4.0.
The rationale behind this move is crucial: schema updates must execute during plugin bootstrap, before WordPress processes any background or frontend requests that could log an email.
For instance, the new transport column must exist before the Email Log attempts to record a message delivered via the fallback server.
This ensures the database upgrade does not depend on an administrator visiting the dashboard before migrations run.
This change was also verified across live test upgrades. I confirmed that the schema migrated properly and that the new column was immediately available to log failover operations.
MySQL 8.0+ Strict Mode Compatibility
I also revised the CREATE TABLE statement to eliminate two problematic definitions:
DEFAULT ''onTEXTcolumns.- The zero-date default
0000-00-00 00:00:00.
These details often slip by unnoticed during initial development, but they can trigger fatal errors when deployed on servers running strict MySQL configurations.
Clean Third-Party Integration and Lifecycle
Another focus area was refining how the plugin extracts email metadata and hooks into the wider WordPress ecosystem.
Payload-Driven Logging
The Email Log now retrieves recipient and subject data directly from the payloads passed to the wp_mail_succeeded and wp_mail_failed hooks.
This eliminates the need to pass email data across callbacks using internal class state.
However, the plugin does retain minimal operational state during the sending cycle to track the active transport and log initial primary server errors whenever the fallback server successfully recovers delivery.
This creates a cleaner separation of concerns between message data (supplied by WordPress) and transport diagnostics (maintained by the failover mechanism).
It is also worth remembering what a successful log entry actually indicates: wp_mail_succeeded confirms that PHPMailer handed the message off without error. It does not prove that the message landed in the recipient’s inbox. Downstream delivery remains up to the upstream SMTP server and receiving mail exchangers.
Honoring Custom From Headers
If the plugin’s sender settings are left blank, From and FromName headers set by third-party plugins are respected.
This improves compatibility with plugins like WooCommerce or Contact Form 7, which specify custom sender headers when generating notifications.
The objective is to prevent Tinio SMTP Mailer’s global configuration from unnecessarily overriding settings from other plugins.
Clean Uninstallation
An uninstall.php script was added to clean up options, custom tables, and scheduled WP-Cron events whenever the plugin is uninstalled.
This is essential for keeping the database tidy and leaving no residual artifacts behind if an administrator decides to remove the plugin entirely.
4. Admin UI Redesign and Translations (v1.4.0)
The three core admin views (Configuration, Email Log, and Send Email) were unified under a responsive layout system built on 1200px max-width cards and a 12-column CSS Grid.
The goal was not merely aesthetic, but functional: better structuring a settings interface that now accommodates two SMTP profiles, debug settings, and log management tools.
Accessible Tabbed Settings
The configuration screen is divided into three distinct tabs:
- Primary SMTP: Settings for the main SMTP server.
- Fallback Server: Settings for the secondary server, featuring a visual status indicator.
- Logs & Debug: Email logging rules and debugging options.
On mobile viewports of 640px or less, tabs automatically stack as full-width responsive buttons.
The interface incorporates ARIA roles, focus management, and keyboard navigation. Arrow keys allow navigating between tabs, while Home and End jump to the first and last tabs, respectively.
Tab state is also preserved across page reloads using sessionStorage, sparing administrators from having to re-select the tab they were working on.
Usability Improvements
Additional enhancements include:
- Progressive disclosure for authentication, fallback, and logging fields.
- A visual indicator for stored credentials (
✓ Saved (AES-256-GCM)). - Preserving existing passwords when saving settings with an empty password field.
- A toggle button to show or hide passwords.
- Contextual port suggestions based on the selected encryption method.
- Direct log purge and clear actions accessible from the Email Log view.
These subtle touches reduce cognitive overhead and make ongoing administration significantly smoother.
Complete Spanish Translation
A complete Spanish translation (es_ES) was implemented.
Coverage spans configuration strings, status alerts, log table badges, and all new failover options.
The goal was to ensure that adding new features did not result in an inconsistent, half-translated interface across different administrative screens.
5. How to Upgrade
The current system requirements for Tinio SMTP Mailer are:
- WordPress: 6.4 or higher (tested up to WordPress 7.0+).
- PHP: 8.1 or higher (PHP 8.3+ recommended).
- PHP Extension: OpenSSL.
Upgrading from earlier versions automatically handles both the database schema migration and the password re-encryption to AES-256-GCM.
There is no need to re-enter SMTP credentials as long as the migration routine can successfully decrypt legacy payloads.
As a best operational practice, I recommend taking a database backup and keeping your WordPress security keys unchanged during the upgrade process.
The source code is released under the GPL-2.0 license on the GitHub repository, and ready-to-install ZIP archives are available from the Releases page.