SMTP and smart routing
OM_SMTP manages every outbound connection. Multiple connections are supported with a primary and an optional backup.
Supported providers
| Provider | Host | Port | Encryption |
|---|---|---|---|
| Gmail / Google Workspace | smtp.gmail.com | 587 | TLS |
| Microsoft 365 / Outlook | smtp.office365.com | 587 | TLS |
| Amazon SES | region-specific | 587 | TLS |
| Zoho Mail | smtp.zoho.com | 587 | TLS |
| Custom | configurable | configurable | TLS or SSL |
Gmail requires an App Password (2FA must be on). Microsoft 365 needs SMTP AUTH enabled per mailbox in Exchange Admin Center. Amazon SES requires SMTP credentials from IAM, not regular access keys, and production access must be requested to leave the sandbox.
Connection structure
Connections live in the om_smtp_connections option (array, passwords encrypted). Routing lives in om_smtp_routing:
php[ 'primary' => 'conn_id', 'backup' => 'conn_id' ]Failover via OM_Smart_Routing
- Every send uses the primary connection.
- On failure (
wp_mail_failedhook), OMailer switches to the backup for the rest of the batch. - After the batch completes, the primary is reinstated.
PHP API
php$smtp = new OM_SMTP();
$connections = $smtp->get_connections();
$smtp->save_connection( 'conn_id', $data );
$primary_id = $smtp->get_primary_id();
$result = $smtp->send_test( 'conn_id', 'recipient@example.com' );Hooks
php// Fired when failover activates
add_action( 'om_smtp_failover', function( string $failed_id, string $backup_id ) {}, 10, 2 );
// Filter to override connection per send
add_filter( 'om_resolve_smtp_connection', function( string $id, array $mail ) {
return $id;
}, 10, 2 );
