=== Changrid Email Delivery ===
Contributors: tuanpm094
Tags: email, transactional email, smtp alternative, delivery, wp mail
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Send WordPress email through Changrid. Start free, then add provider routing, delivery visibility, and controlled native-mail fallback.

== Description ==

Changrid Email Delivery connects WordPress `wp_mail()` calls to a Changrid workspace through the dedicated, API-key-protected WordPress endpoint.

The plugin is free, and you can start sending with Changrid's Free plan. Upgrade only when you need more sending capacity, routing, retention, workspace capacity, or provider options.

Features:

* Uses workspace access and secret keys; no WordPress user password is shared.
* Start sending with the Changrid Free plan; no separate plugin license is required.
* Routes normal WordPress mail, including HTML and plain-text messages.
* Supports To, Cc, Bcc, and Reply-To addresses.
* Keeps the From identity protected by Changrid provider configuration while allowing an optional site-wide Reply-To address.
* Optional open, click, and unsubscribe tracking.
* Optional fallback to native `wp_mail()` after a Changrid request error.
* Sends one explicit test message from the settings screen.
* Checks credentials and send permission without sending an email.
* Keeps automatic workspace routing as the recommended default, with an advanced fixed-provider option for strict route control.
* Keeps a small local diagnostic log without recipient addresses, subjects, or message bodies.
* Supports constants in `wp-config.php` so production secrets do not need to be stored in the WordPress database.

Changrid returns an accepted/queued response. Acceptance is not proof of final delivery. Final status and provider events remain available in the Changrid workspace where supported by the configured provider.

This plugin currently does not send attachments through Changrid. When fallback is enabled, messages with attachments continue through native `wp_mail()`.

== External service ==

This plugin sends email data to the Changrid service when the site owner enables Changrid delivery. The request may contain recipient email addresses and names, the email subject and body, Reply-To addresses, tracking preferences, and a generic plugin-version User-Agent. The User-Agent does not include the WordPress site URL. Changrid uses this data to enqueue and operate the requested communication through the workspace's configured provider route.

Service links:

* Changrid: https://changrid.com/
* Documentation: https://changrid.com/docs
* Terms: https://changrid.com/legal/terms
* Privacy policy: https://changrid.com/legal/privacy
* Acceptable use: https://changrid.com/legal/acceptable-use

The service is not contacted until the plugin is configured and a message is sent, or the administrator deliberately presses the connection-check or test button.

The connection-check button contacts Changrid only after the administrator has
configured credentials and deliberately starts the check. It verifies the key
and the `communications:send` scope and loads active email provider choices
without creating an email.

== Plans and billing ==

The WordPress plugin itself is free and GPL-licensed. A Changrid account is
required to use the hosted delivery service. Changrid has a Free plan and paid
plans with different managed-message allowances, routing features, retention,
workspace capacity, and provider options. Current prices and limits are shown
at https://changrid.com/pricing and are supplied by Changrid's live plan catalog.

Your WordPress hosting, domain, and any bring-your-own provider charges are
separate from the Changrid subscription. BYOP traffic and managed-delivery
allowances may be treated differently by the selected Changrid plan; review the
live plan details before upgrading.

== Installation ==

1. Upload the plugin ZIP in Plugins > Add New > Upload Plugin, or copy the `changrid-email-delivery` directory into `/wp-content/plugins/`.
2. Activate the plugin.
3. Open Settings > Changrid Email.
4. Create a workspace access key with `communications:send` permission in Changrid.
5. Enter the access key and secret key, then save the settings.
6. Optionally set a default Reply-To address for replies to website email.
7. Press Check connection. This does not send an email.
8. Keep Automatic workspace routing (recommended), or choose a fixed active provider under Advanced delivery routing and save again.
9. Send one test to an address you control.
10. Verify the accepted execution and final delivery state in Changrid before enabling production routing.

To disconnect the site, disable Changrid delivery, clear the access key, select the remove-stored-secret option, save, and revoke the integration key in Changrid.

For production, credentials can be stored in `wp-config.php`:

`define( 'CHANGRID_ACCESS_KEY', 'your-access-key' );`

`define( 'CHANGRID_SECRET_KEY', 'your-secret-key' );`

The optional `CHANGRID_API_BASE_URL` constant overrides the API base URL.

== Screenshots ==

1. Connect WordPress to Changrid with a workspace key, protected sender identity, and live email-credit visibility.
2. Keep automatic workspace routing for health-aware provider selection and failover while monitoring quotas and purchased credits.
3. Choose a fixed managed or bring-your-own provider when strict sender routing is required, with a clear warning that automatic failover is disabled.
4. Review privacy-conscious local delivery diagnostics without storing recipient addresses, subjects, or message content.

== Frequently Asked Questions ==

= Does this replace SMTP? =

It short-circuits `wp_mail()` and submits the message to Changrid over HTTPS. The actual provider path is selected and operated in the Changrid workspace.

= Do I need to configure an API base URL? =

No. The plugin automatically uses Changrid's secure production API. The `CHANGRID_API_BASE_URL` constant is only for advanced or self-hosted installations and is not required for normal setup.

= Does accepted mean delivered? =

No. HTTP 202 means Changrid persisted or accepted the request. Delivery depends on routing, provider state, sender identity, suppression checks, and the recipient system.

= What happens when Changrid is unavailable? =

If native-mail fallback is enabled, the plugin lets WordPress continue with its normal `wp_mail()` transport after a request error. It does not retry a response that Changrid reported as accepted.

A network timeout is ambiguous: Changrid may have accepted the request even though WordPress did not receive the response. Native fallback in that situation can deliver a duplicate. Disable fallback for duplicate-sensitive messages and review the Changrid execution before manually retrying an uncertain send.

= Are attachments supported? =

Not in this release. Messages with attachments use native `wp_mail()` when fallback is enabled, or fail if strict Changrid-only behavior is selected.

= Are Cc and Bcc headers preserved? =

All To, Cc, and Bcc destinations are submitted as individual Changrid recipients. They do not receive a visible shared recipient header, which keeps Bcc destinations private.

= Can I change the From address in WordPress? =

No. The From email and name come from the active provider route in Changrid. This prevents WordPress from requesting an unverified identity that would fail provider, SPF, DKIM, or DMARC checks. Use the plugin links to manage providers or verify a sending domain in Changrid. WordPress can set a per-message Reply-To header, and the plugin also supports an optional site-wide default Reply-To address.

= Can I choose a specific email provider? =

Yes. Automatic workspace routing is the recommended default because Changrid can apply route priority, health, capacity, and failover rules. After pressing Check connection, open Advanced delivery routing to choose an active provider. A fixed provider controls the sender route but disables automatic failover for those WordPress requests.

== Privacy ==

The local activity log stores UTC time, result, recipient count, execution ID, HTTP status, and an error code. It does not store recipient addresses, subject lines, or message content. Uninstalling the plugin deletes its settings and local log.

Enabling open or click tracking may have privacy and consent implications in your jurisdiction. Those options are off by default. Site owners are responsible for their notices, consent choices, retention settings, and lawful use.

== Changelog ==

= 0.5.0 =

* Added a guided provider selector populated by the deliberate no-send connection check.
* Kept automatic workspace routing as the recommended default and moved fixed routing into an advanced section.
* Shows managed-versus-own-provider and sender details without exposing or manually entering provider IDs.
* Sends `providerAccountId` only when a valid fixed provider is saved.

= 0.4.0 =

* Added a sender-identity section with direct links to Changrid provider and sending-domain settings.
* Added an optional site-wide Reply-To address while preserving per-message Reply-To precedence.
* Clarified that From identities are selected from verified Changrid provider routes and cannot be overridden by WordPress.

= 0.3.0 =

* Added a no-send connection and permission check.
* Added clear plans, billing, setup, integration, and troubleshooting guidance.
* Clarified that the plugin is free and works with Changrid's Free plan.
* Improved WordPress.org external-service disclosure and release documentation.

= 0.2.0 =

* Initial release.
* Dedicated Changrid WordPress API delivery for `wp_mail()`.
* Test-send flow, privacy-conscious local diagnostics, tracking controls, and native-mail fallback.

== Upgrade Notice ==

= 0.5.0 =

Adds automatic-versus-fixed provider routing controls with clear sender and failover guidance.

= 0.4.0 =

Adds safe sender-identity guidance and an optional default Reply-To address.

= 0.3.0 =

Adds no-send connection diagnostics and expanded setup and billing guidance.

= 0.2.0 =

Initial release.
