=== MME-Mail to SMTP ===
Contributors: mmeprowp
Tags: smtp, wp_mail, gmail, sendgrid, mailgun
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 0.16.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Sends WordPress email through Gmail, SendGrid, Mailgun, Brevo, Postmark, Resend, SMTP2GO or any SMTP server - and tells you when a message fails.

== Description ==

WordPress sends email with `wp_mail()`, which hands the message to the web server's own mail function. On most hosts that mail lands in spam or never arrives, and nothing on the site says so, because almost no code checks what `wp_mail()` returned. Sites often go weeks before anyone notices the receipts stopped.

This plugin routes your mail through a real mail service, and makes failure visible.

= Why this one =

* **No email log, on purpose.** A table of every message sent - recipients, subjects, often the body - is a liability waiting for the next breach. This plugin keeps no copy of what it sent. It tells you instead whether sending works right now, what the last error was, and what is queued.
* **A retry queue, in the free plugin.** A message lost to a brief network fault is persisted and retried over the following hours. A failure no retry can fix - an oversized attachment, a rejected recipient - is reported straight away.
* **Errors that name the fix.** "The service account is not authorized to impersonate this mailbox, so authorize its client ID in Google Workspace Admin" - not "HTTP 401".
* **Nothing is sent to the plugin's author.** No registration, no check-in, no usage statistics, no account. The only servers contacted are the ones listed under External services.

= Connections =

* **Google Workspace**, with a service account and domain-wide delegation. No consent screen, no refresh token, nothing that expires.
* **Gmail**, with a standard OAuth sign-in, for accounts outside a Workspace domain.
* **SendGrid, Mailgun, Brevo, Postmark, Resend and SMTP2GO**, with an API key.
* **Any SMTP server**, including services not named above.

One connection is active at a time, and every message goes out over it.

= When sending fails =

* `wp_mail()` returns an accurate result, and `wp_mail_failed` fires with a real error rather than a bare `false`.
* After a number of failures in a row that you choose, an admin notice appears and the **Email delivery** check under Tools > Site Health turns red with the last error. One success clears both.
* Hooks for your own monitoring: `mmoa_send_attempted`, `mmoa_send_failed`, `mmoa_send_failing` (an outage starts) and `mmoa_send_recovered` (it ends).

= Also =

* Every connection accepts a complete RFC 822 message, so what PHPMailer builds is what gets sent. Attachments, inline images, Reply-To, Cc, Bcc and custom headers are handled by WordPress core, not rebuilt by hand.
* Credentials can live in `wp-config.php`; anything stored in the database is encrypted with libsodium.
* A setup wizard connects the service, verifies the credentials, and sends one real test message before you rely on it.
* Privacy requests are answered through WordPress's own Export and Erase Personal Data tools.

== External services ==

This plugin sends your outgoing email through the service you configure. Nothing is transmitted until you configure one.

**Google (OAuth 2.0 and the Gmail API)** - used by either Google connection.

* `https://oauth2.googleapis.com` - receives a signed assertion or your refresh token, in exchange for a short-lived access token.
* `https://gmail.googleapis.com` - receives the complete outgoing email.
* Terms: https://policies.google.com/terms - Privacy: https://policies.google.com/privacy

**SendGrid** - `https://api.sendgrid.com`. Terms: https://www.twilio.com/en-us/legal/tos - Privacy: https://www.twilio.com/en-us/legal/privacy

**Mailgun** - `https://api.mailgun.net` or `https://api.eu.mailgun.net`, depending on your region. Terms: https://www.mailgun.com/legal/terms/ - Privacy: https://www.mailgun.com/legal/privacy-policy/

**Brevo** - `https://api.brevo.com`. Terms: https://www.brevo.com/legal/termsofuse/ - Privacy: https://www.brevo.com/legal/privacypolicy/

**Postmark** - `https://api.postmarkapp.com`. Terms: https://postmarkapp.com/terms-of-service - Privacy: https://postmarkapp.com/privacy-policy

**Resend** - `https://api.resend.com`. Terms: https://resend.com/legal/terms-of-service - Privacy: https://resend.com/legal/privacy-policy

**SMTP2GO** - `https://api.smtp2go.com`. Terms: https://www.smtp2go.com/terms/ - Privacy: https://www.smtp2go.com/privacy/

Each of these receives your API key and the complete outgoing email: sender, recipients, subject, body and attachments.

**Your own SMTP server** - used when Other SMTP is selected. The message goes only to the host and port you enter.

No other service is contacted, including none run by the plugin's author.

== Source code ==

The full source is public: https://github.com/MME-pro/mme-mail-to-smtp-lite

All PHP is plain source. The admin interface (`build/index.js`, `build/index.css`) is compiled with `@wordpress/scripts` from the React sources in `src/`, which ship with the plugin.

== Installation ==

1. Install and activate the plugin.
2. Go to **MME-Mail to SMTP** in the admin menu. The setup wizard opens on first run.
3. Choose a mail service and enter its credentials, or sign in to Google.
4. Send the test message the wizard offers. If it arrives, you are done.

Credentials can also be set in `wp-config.php` instead of the database, for example `define( 'MMOA_GOOGLE_SA_PRIVATE_KEY', '...' );`. A field set this way is shown as pinned.

== Frequently Asked Questions ==

= Do I need a Google Workspace account? =

Only for the service account connection, because domain-wide delegation is a Workspace feature. A plain @gmail.com account uses the Gmail OAuth connection instead.

= My Gmail connection stops working every week. =

Your Google Cloud consent screen is still in Testing status, which expires refresh tokens after seven days. Set it to In production and reconnect.

= Why does the service account connection say it cannot impersonate the mailbox? =

Its client ID has not been authorized in Google Workspace Admin under Security > API Controls > Domain-wide Delegation, with the `https://www.googleapis.com/auth/gmail.send` scope.

= How large can attachments be with Google? =

About 2 MB. The Gmail API caps a request at 4-5 MB, and the message is base64-encoded twice on this path, so the usable size is roughly half. Oversized messages are rejected before sending, with a message saying so.

= Is there an email log? =

No, deliberately. The plugin keeps no copy of what it sent. It shows whether sending currently works, the last error, and what is waiting in the retry queue.

= Can another mailer plugin be active at the same time? =

No. Only one plugin can take over sending, and which one wins depends on load order. The plugin detects the common ones and warns you on screen.

== Screenshots ==

1. Choose one of eight mail services; every message goes out over the one you pick.
2. The dashboard: whether mail is being delivered right now, the last error, and the retry queue.
3. A configured Google Workspace connection. The signing key is stored encrypted and never shown back.
4. The setup wizard: choose a service, enter credentials, verify them, and send a test message.
5. Settings: how many failures in a row count as an outage, how long the retry queue holds a message, and privacy tools.

== Changelog ==

= 0.16.0 =
* First public release.

== Support ==

Written and maintained by MME-pro (https://mme-pro.de/).

For help, write to support@mme-pro.de. Include the plugin version (shown in the footer of the plugin screen) and, if sending is failing, the error text from Tools > Site Health.
