=== SMTP Mail Relay ===
Contributors: 404ops
Tags: smtp, gmail, email log, mailer, deliverability
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Route WordPress email through SMTP, Gmail, SendGrid, SES, Mailgun, Postmark or Brevo — with a full searchable email log, resend, and export. Free.

== Description ==

SMTP Mail Relay routes your WordPress site's outgoing email through the mailer you choose — your own SMTP server, your own Gmail or Google Workspace account, your own Outlook.com or Microsoft 365 account, or the SendGrid, Amazon SES, Mailgun, Postmark, or Brevo API — and keeps a full log of every send attempt.

The free plan is a complete email-delivery toolkit, not a crippled trial:

* **Eight mailers, one screen.** SMTP, Gmail/Google Workspace, Outlook.com/Microsoft 365, SendGrid, Amazon SES, Mailgun, Postmark, and Brevo, all behind one Mailers screen with a test-send button. Outlook and Microsoft 365 sit behind every competitor's own paywall — here they're free, same as everything else on this screen.
* **Automatic failover to a backup mailer.** Pick any second configured mailer on the Mailers screen. When the active mailer refuses a send, that message is immediately re-sent through the backup instead of being lost — for API mailers and SMTP alike, with both attempts recorded in the email log. No licence, no send limit, no trial period.
* **Gmail and Google Workspace, on your own OAuth client.** You create the Google Cloud project and paste in your own client ID and secret — there is no relay service in the middle and no third party holding your tokens. The plugin asks Google for one permission only, `gmail.send`, and never for read access to your mail. Setting up the Google Cloud project takes about 15 minutes the first time; the screen shows you the exact redirect URI to register and tells you so up front.
* **Outlook.com and Microsoft 365, on your own app registration.** You register the app in your own Microsoft Entra admin center and paste in your own application (client) ID and secret — same bring-your-own-credentials design as Gmail, no relay service and no third party holding your tokens. The plugin asks Microsoft Graph for `Mail.Send` (to send) and `User.Read` (Microsoft's own default sign-in permission, used only to show which account is connected) — never `Mail.ReadWrite`, which would grant access to your whole mailbox. One app registration works for both a Microsoft 365 work account and a personal Outlook.com/Hotmail account.
* **Full, searchable email log.** Every send attempt with recipient, subject, status, mailer, source plugin, and the provider's response. Filter, search, and page through it.
* **One-click resend** for any logged message, and **CSV export** with optional recipient masking.
* **Configurable retention** — 30 days, 90 days, 1 year, or forever — auto-pruned daily.
* **Free SPF/DKIM/DMARC domain-authentication checker** for your sending domain.
* **BYOK AI Diagnose.** Plain-English explanation of a failed or bounced send, using your own OpenAI, Anthropic, Gemini, Ollama, OpenRouter key, or a self-hosted OpenAI-compatible endpoint (LM Studio, vLLM, LocalAI, Azure OpenAI, and similar). Every diagnosis is propose → preview → approve → execute, with a full audit trail — the AI never sends anything on its own.
* **Credentials encrypted at rest** — your SMTP password, mailer API keys, and BYOK AI key, never logged or exported in the clear.
* **Import from your current SMTP plugin.** One screen that reads the settings already saved by WP Mail SMTP, Easy WP SMTP, Post SMTP or FluentSMTP and brings them across — host, port, encryption, username, sending domain, region, From name/address, force-from and Return-Path — including, wherever the other plugin kept it in the database, the credential itself, decrypted or decoded and then re-stored encrypted at rest here. It shows you exactly what will be imported before it writes anything, never touches the other plugin's own settings, and saves a copy of your current configuration first so a single click puts it back.
* **A guided first-run setup wizard.**

This plugin carries no admin-notice ads, no upgrade nags, and no artificially crippled free tier. Where Pro is named — on the License tab, and beside the features it extends — it is described factually, never as a pop-up or a countdown sale. The one admin notice it ever shows goes to an existing Pro site whose licence has stopped revalidating: a service warning, not a sales pitch.

= Pro (from $29/year) =

Pro adds three things on top of the free plan:

* **A circuit breaker over that failover, plus an incident log.** Free failover retries every failed message through the backup, which is the right thing to do when nothing is remembered between sends. Pro remembers: after a run of consecutive failures it stops attempting the dead primary at all, routes straight to the backup for a cooldown period, then probes the primary once and switches back the moment it recovers — and writes every activation and recovery to the audit log as an incident you can read afterwards.
* **Proactive deliverability alerts** — failure-rate spikes, lost domain authentication, and automatic-failover notifications — delivered by email, or straight into Slack, Discord, Microsoft Teams or Telegram, or to your own webhook. You paste the address the chat service gives you; the plugin formats the message that service expects. Chat alerts do not go through your mailer, so they still arrive when email is the thing that has broken.
* **A weekly AI deliverability report**: a plain-English narrative, healthy/degraded signals, and settings recommendations, emailed and archived every week using your own BYOK AI key.

Pro starts at $29/year for one site, with 5-site and unlimited tiers, and renews at the price you paid. No introductory discount that doubles in year two, no fake sales, no feature held hostage from the free plan to sell it back to you.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/smtp-mail-relay`, or install through the WordPress Plugins screen directly.
2. Activate the plugin through the "Plugins" screen in WordPress.
3. The first-run wizard walks you through choosing a mailer (SMTP or an API provider) and entering its credentials.
4. Send a test email to confirm delivery, then check the Email Log tab to review send activity.
5. Already running another SMTP plugin? Open the **Import** tab instead — it reads that plugin's saved settings and shows you what would be brought across before anything is written.
6. The plugin lives at **404ops → Mail Relay** in the admin menu — every 404ops plugin on the site shares that one "404ops" menu rather than taking a sidebar slot each. Its own sections (Dashboard, Logs, Mailers, Import, Alerts, AI, Advanced, License, Settings) are tabs across the top of that screen.

== Frequently Asked Questions ==

= Does this plugin make any external requests? =

Only to the mailer you configure — your own SMTP server, your own Gmail/Google Workspace account (via Google's own OAuth and Gmail API endpoints, using an OAuth client you create and own), your own Outlook.com/Microsoft 365 account (via Microsoft's own OAuth and Graph API endpoints, using an app registration you create and own), or the SendGrid, Amazon SES, Mailgun, Postmark, or Brevo API — to send your site's outgoing email. If you connect an AI provider (OpenAI, Anthropic, Gemini, Ollama, OpenRouter, or your own self-hosted OpenAI-compatible endpoint), the plugin also contacts that endpoint when you use AI Diagnose or the Pro weekly report, and only then — a self-hosted endpoint never leaves your own infrastructure. The domain-authentication checker performs standard DNS lookups (SPF/DKIM/DMARC) against the public DNS system for whatever domain you check. On Pro, a fired alert is also POSTed to whichever alert channels you configured, and only those: your own webhook URL, the Slack, Discord or Microsoft Teams webhook address you pasted in, and — for Telegram — api.telegram.org, which is where its Bot API lives. Nothing else leaves your site. Optional, opt-in usage telemetry (versions, tier, mailer type, a coarse send-volume bucket — never email content, addresses, credentials, or domains) is recorded locally for you to review; it is not transmitted anywhere.

= What data does each external service receive, and what are their own terms and privacy policies? =

Sending a message through a mailer necessarily hands that mailer what it needs to deliver it — recipient address(es), subject, message body, headers, and any attachments, plus whichever sender identity (From name/address, Return-Path) you've configured. That is true of SMTP, Gmail/Google Workspace, and every API mailer alike, and is the plugin's core function rather than an extra disclosure. Where that provider is a paid or hosted third-party service, its own terms and privacy policy govern what happens to that data once it arrives: SendGrid ([Twilio Terms](https://www.twilio.com/en-us/legal/tos), [Privacy](https://www.twilio.com/en-us/legal/privacy)), Amazon SES ([AWS Service Terms](https://aws.amazon.com/service-terms/), [Privacy](https://aws.amazon.com/privacy/)), Mailgun ([Terms](https://www.mailgun.com/legal/terms/), [Privacy](https://www.mailgun.com/legal/privacy-policy/)), Postmark ([Terms](https://postmarkapp.com/terms-of-service), [Privacy](https://postmarkapp.com/privacy-policy)), Brevo ([Terms](https://www.brevo.com/legal/termsofuse/), [Privacy](https://www.brevo.com/legal/privacypolicy/)), Google, for Gmail/Google Workspace sending ([Terms](https://policies.google.com/terms), [Privacy](https://policies.google.com/privacy)), and Microsoft, for Outlook.com/Microsoft 365 sending ([Terms](https://www.microsoft.com/en-us/servicesagreement), [Privacy](https://www.microsoft.com/en-us/privacy/privacystatement)).

AI Diagnose (free) never sends the message body, headers, or attachments of the email it's explaining — only that log row's own metadata: the recipient address (masked to its first character and domain by default — "AI" tab → "Mask recipients", on by default), the subject line, the send status, which mailer and source plugin were involved, the mailer's own error/response text, and the sending domain's SPF/DKIM/DMARC verdicts. The Pro weekly report sends less still: aggregate counts (volume, failure rate, bounce categories, top failing domains, domain-auth status) across the whole reporting period, never anything tied to one message or recipient. Both features are BYOK and opt-in by construction — nothing reaches an AI provider until you paste in your own key and use the feature — and route only to the provider you configured: OpenAI ([Terms](https://openai.com/policies/terms-of-use), [Privacy](https://openai.com/policies/privacy-policy)), Anthropic ([Terms](https://www.anthropic.com/legal/commercial-terms), [Privacy](https://www.anthropic.com/legal/privacy)), Google Gemini ([Terms](https://ai.google.dev/gemini-api/terms), [Privacy](https://policies.google.com/privacy)), or OpenRouter ([Terms](https://openrouter.ai/terms), [Privacy](https://openrouter.ai/privacy)). Ollama and a self-hosted OpenAI-compatible endpoint (LM Studio, vLLM, LocalAI, Azure OpenAI, and similar) are your own infrastructure, not a third party, so no external terms apply.

A Pro alert POST carries only what the notice itself says — a failure-rate percentage, which condition tripped, which mailer or domain is affected — never a recipient address or message content. Where that goes to a chat service rather than your own webhook, that service's own terms and privacy policy apply: Slack ([Terms](https://slack.com/terms-of-service), [Privacy](https://slack.com/trust/privacy/privacy-policy)), Discord ([Terms](https://discord.com/terms), [Privacy](https://discord.com/privacy)), Microsoft Teams ([Terms](https://www.microsoft.com/en-us/servicesagreement), [Privacy](https://www.microsoft.com/en-us/privacy/privacystatement)), and Telegram ([Terms](https://telegram.org/tos), [Privacy](https://telegram.org/privacy)).

= Is my SMTP password / API key stored securely? =

Yes. SMTP passwords, mailer API keys, and your BYOK AI key are encrypted at rest on your own site (libsodium, with an authenticated OpenSSL AES-256-GCM fallback when libsodium isn't available), using a key generated once on your site and never exported, displayed, or logged in the clear.

= Where is the data stored? =

Every setting, the email log, and the audit log are stored in your site's own database.

= What happens to my data if I uninstall the plugin? =

By default, nothing. Deactivating — or even removing — the plugin leaves your settings and email log in place. If you check "Remove all data when this plugin is uninstalled" on Settings → Advanced, then *removing* the plugin (not merely deactivating it) permanently deletes the email log, the audit log, every setting, and every stored credential. Deactivating never deletes anything, regardless of this setting.

= Can I move my settings over from another SMTP plugin? =

Yes, from **WP Mail SMTP**, **Easy WP SMTP** (both its current settings and the older 1.x format), **Post SMTP** and **FluentSMTP**, on the Import tab. Mail Relay reads whichever of those plugins has settings saved on the site — it reads the saved settings themselves, so it works whether or not the old plugin is still active — and shows you a preview first: which mailer was found, which of Mail Relay's mailers it maps onto, every field that carries across, every setting that has no equivalent here, and exactly where each credential stands. Nothing is written until you confirm.

Credentials are the part that varies. Where the other plugin stored one in the database, Mail Relay reads it — decrypting or decoding whichever scheme that plugin used — and re-stores it encrypted at rest, the same way a password you typed in yourself is protected. Where the credential lives only in a `wp-config.php` constant, it was never in the database and cannot be migrated: the preview names the exact constant so you know which value to re-enter, and the rest of the connection is still imported. Where it is an OAuth connection (Gmail, Outlook, Zoho), the token belongs to the other plugin's own registered application and cannot be reused by anything else, so that connection is refused rather than half-imported.

The same honesty applies to mailers. Mail Relay has drivers for SMTP, Amazon SES, Mailgun, SendGrid, Postmark and Brevo (Sendinblue); if the other plugin is sending through something else, that connection is listed as skipped with the reason, never quietly rewritten as a generic SMTP connection that would not work.

= Does importing change or delete anything in my old SMTP plugin? =

No. The importer only ever reads — it never writes to, clears or deactivates the other plugin, so if the result is not what you wanted, that plugin is still configured exactly as it was and you can switch straight back. On Mail Relay's own side, an import over an existing configuration requires an explicit confirmation, takes a copy of what was there first, and leaves an "Undo" button on the Import tab.

= Can I bring my old plugin's email log across too? =

From Post SMTP and FluentSMTP, yes — recipient, subject, delivery status and timestamp, with message bodies and headers included only if you have "Store message content" switched on. Large logs are copied in batches, so run the import again to continue. WP Mail SMTP and Easy WP SMTP keep no per-email log in their free versions (theirs is a paid add-on; what the free versions record is error text and the calling file, with no recipient, subject or status), so there is nothing there to import and the Import tab says so.

= Does the email log guarantee accurate delivery status? =

No. Each attempt gets one row, opened as "pending" and then resolved to "sent" or "failed" from what the mailer reported once the send returned. It is a record of send attempts, not a delivery-confirmation service: "sent" means the mailer accepted the message, not that it reached the inbox — no provider driver in this plugin currently ingests bounce webhooks, so a status can only ever reflect what was known at the moment of sending.

== Screenshots ==

1. The dashboard: delivery rate, recent failures, and which mailer sent what.
2. Every message the site tried to send, with its status, source and error.
3. Configure a mailer and test the connection before you rely on it.
4. The setup wizard walks a new site through its first working mailer.

== Changelog ==

= 1.1.1 =
* Fix: Pro update checks select this plugin's uploaded package and remove stale update offers when licensing or release lookup fails.
* Fix: WordPress Pro updates require a compatible Free version, with update protection still registered when Free is missing or older.
* Maintenance: Keep the Free and Pro versions aligned for the updated add-on.

= 1.1.0 =
* New: Outlook.com and Microsoft 365 mailer, on your own Microsoft Entra app registration — bring-your-own-credentials OAuth, same design as the existing Gmail/Google Workspace mailer. Requests only `Mail.Send` (to send) and `User.Read` (Microsoft's own default sign-in permission, to show which account is connected) — never `Mail.ReadWrite`. Free, with no licence required, same as every other mailer in this plugin.

= 1.0.6 =
* New (Pro): a quiet, dismissible admin notice now appears once this add-on's licence hasn't revalidated successfully in a few days, before Pro features would otherwise silently lapse with no warning. Updated the shared licence client.
* Fix (Pro): a licence's cached "valid" state is now bounded to 14 days since its last successful check, so a site whose WP-Cron never runs no longer keeps a revoked or expired licence reading active indefinitely.

= 1.0.5 =
* Maintenance release. No functional changes.

= 1.0.4 =
* Fix (Pro): licence activation and update checks used the wrong authentication scheme and an incorrect product filter against the licence server, which could reject valid requests. Updated the shared licence client.

= 1.0.3 =
* Maintenance release. No functional changes.

= 1.0.2 =
* Fix (Pro): first-time licence activation could fail against the real licence server on a brand-new key (updated the shared licence client).

= 1.0.1 =
* Maintenance release. No functional changes.

= 1.0.0 =
* New: SendGrid, Amazon SES, Mailgun, Postmark, and Brevo mailer drivers alongside SMTP, selectable from one Mailers screen.
* New: full searchable/filterable email log with per-message detail, one-click resend, CSV export, source-plugin attribution, and configurable retention (30 days/90 days/1 year/forever).
* New: free SPF/DKIM/DMARC domain-authentication checker.
* New: BYOK AI Diagnose — plain-English bounce/failure diagnosis using your own OpenAI, Anthropic, or Gemini API key, with a propose/preview/approve/execute workflow and a full audit trail.
* New: guided first-run setup wizard.
* New (Pro): automatic failover to a backup mailer with a circuit breaker and incident log.
* New (Pro): proactive deliverability alerts (failure-rate spikes, lost domain authentication, and failover notifications) by email or webhook.
* New (Pro): weekly AI deliverability report with a browsable archive.
* New: opt-in uninstall cleanup (Settings → Advanced) that permanently removes all plugin data when the plugin is uninstalled.

= 0.1.0 =
* Initial release: SMTP configuration, test email, and send-attempt logging with status filtering.

== Upgrade Notice ==

= 1.1.0 =
New: Outlook.com and Microsoft 365 mailer, bring-your-own-credentials OAuth, free on every tier.

= 1.0.6 =
Pro now shows an early warning notice before licence-related features would lapse, and no longer keeps a revoked or expired licence active forever on a site whose WP-Cron never runs. Pro users should update.

= 1.0.5 =
Maintenance release. No functional changes.

= 1.0.4 =
Fixes Pro licence activation and update checks against the real licence server. Pro users should update.

= 1.0.3 =
Maintenance release. No functional changes.

= 1.0.2 =
Fixes first-time Pro licence activation. Pro users on a licence that has never activated before should update.

= 1.0.1 =
Maintenance release. No functional changes.

= 1.0.0 =
First public release. SMTP plus SendGrid, Amazon SES, Mailgun, Postmark and Brevo, a full searchable email log with resend and CSV export, a free SPF/DKIM/DMARC checker, and BYOK AI failure diagnosis. Pro adds mailer failover and deliverability alerts.
