=== Ternwire ===
Contributors: ternwire
Tags: email, wp_mail, transactional email, smtp, deliverability
Requires at least: 5.9
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send all WordPress email through the Ternwire transactional email API.

== Description ==

Ternwire replaces delivery inside wp_mail(), so password resets, new user notices, form notifications and store receipts go through the Ternwire API over HTTPS. Other plugins keep calling wp_mail() as before.

* Works on hosts that block outbound SMTP ports.
* Attachments are checked for an allowed file type before wp_mail() returns.
* Temporary API failures are retried once at once and then in the background through WP-Cron, always with the same idempotency key, so a retry never sends twice.
* The settings page lists the last 20 sending problems.
* Failures fire wp_mail_failed, so email logging plugins keep working.
* Settings can live in wp-config.php constants instead of the database.

The plugin sends email to the Ternwire API at https://ternwire.com, or the API origin you configure. Each email's recipients, subject, body, headers and attachments are sent to that service. Read the [Ternwire privacy policy](https://ternwire.com/privacy) and [terms](https://ternwire.com/terms).

== Installation ==

1. Download the plugin zip from https://ternwire.com/downloads/ternwire-wordpress.zip, upload it from Plugins > Add New Plugin > Upload Plugin and activate it.
2. Create an API key with send access in the Ternwire dashboard.
3. Open Settings > Ternwire, paste the key and set a From address on a sending domain you verified in Ternwire.
4. Send a test email from the same page.

To keep the key out of the database, add it to wp-config.php instead:

`define( 'TERNWIRE_API_KEY', 'em_live_...' );`

TERNWIRE_FROM_EMAIL, TERNWIRE_FORCE_FROM and TERNWIRE_API_ORIGIN work the same way. The API origin must use https. Plain http is accepted only for localhost or a loopback address, so the key is never sent in cleartext over a network.

== Frequently Asked Questions ==

= What happens before I add an API key? =

Nothing changes. WordPress keeps sending email the default way until a valid key is saved.

= What name do recipients see as the sender? =

The name in the From header a plugin sets. Without one, your site title. The wp_mail_from_name filter can change it, as with core. Names in To and Cc are dropped.

= Do phpmailer_init hooks still run? =

No. Ternwire builds the message itself, so plugins that change PHPMailer directly have no effect.

= Can I change the request sent to Ternwire? =

Use the ternwire_email_payload filter. It receives the API request body and the wp_mail() arguments.

== Changelog ==

= 0.2.0 =
* Each API call waits at most 8 seconds and is retried once, so a slow API no longer holds a page for a minute and a half.
* An email that still fails for a temporary reason is sent again in the background through WP-Cron, with the same idempotency key, for about five hours.
* The settings page lists the last 20 sending problems. A later successful send no longer hides them.
* Attachments are checked against the 15 MB limit for all files together before any upload.

= 0.1.0 =
* First release.
