=== Casa Mail ===
Contributors: sendemailtoday,codecasastudios
Tags: smtp, email, wp_mail, marketing, deliverability
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.9.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A complete email platform for WordPress: transactional SMTP, marketing campaigns, branded mailboxes, and DKIM-aligned sending from your own domain.

== Description ==

Casa Mail is an end-to-end email platform for WordPress sites. It intercepts every `wp_mail()` call and delivers it through the Casa Mail gateway operated by CodeCasa Studios on the OnlineStoreNotifications infrastructure (api.onlinestorenotifications.com). On top of reliable transactional delivery it adds a full marketing platform, branded webmail mailboxes, and one-click sender-domain authentication, all driven from the WordPress admin.

If your site doesn't send mail reliably today, Casa Mail is the simplest way to start. If you're already paying for an SMTP plugin plus a separate marketing tool plus a separate webmail provider, Casa Mail consolidates the three so you can run customer email, broadcasts, and inbox replies from one place.

= What you get =

**Transactional email (every plan, including Free)**

* Every `wp_mail()` is routed through the Casa Mail gateway with DKIM, SPF, and aligned Return-Path on `onlinestorenotifications.com` (or your own domain after one-click authentication).
* Durable retry outbox: if the gateway is briefly unreachable, the payload is persisted and retried automatically with 30s, 2m, 10m backoff. `wp_mail()` never blocks, never loses a message, never returns false to the caller.
* Per-tenant inbox at `<your-site>@onlinestorenotifications.com`. Replies to your customer emails come back to that inbox; on the Free tier they auto-forward to your contact address. On webmail-enabled plans you can also receive replies on your own domain (e.g. `<your-inbox>@yourdomain.com`).
* Paginated send log on the Logs page with up to 30 days of history retained (hard-capped at 2,000 rows per WordPress install). The Dashboard surfaces the most recent activity at a glance.
* Optional default-From override so every site email uses one consistent sender.

**Sender domain authentication (every plan)**

* Add your own domain in the admin and the plugin prints three DNS records (DKIM, SPF, Return-Path).
* One-click "Check my domain" verifier. Once verified, customer emails go from `<your-inbox>@yourdomain.com` so Gmail and Outlook show your brand in the From, not "via onlinestorenotifications.com".
* Inline plain-English helpers for Cloudflare, GoDaddy, Namecheap, and Google Domains. Cloudflare grey-cloud guidance for replies is built in.
* Free plan can opt out of domain authentication entirely and send from the shared `<your-inbox>@onlinestorenotifications.com` address with DKIM/SPF/Return-Path already configured on the gateway.

**Marketing Studio (Growth and higher)**

* Contacts: add manually, import from CSV, or one-click sync your WooCommerce customer base.
* Segments: saved queries (all contacts, contacts with a specific tag) with a sample-preview before you send.
* Campaigns: schedule a broadcast to a segment, watch send progress on a per-campaign report (sent, opens, unique-by-contact open + click rate).
* Composer: full block-based visual editor with heading / paragraph / image / button / divider / spacer / two-columns / raw-HTML blocks, per-block and global style settings, Visual / Source HTML / Wrapper / Preview tabs, desktop + mobile preview, 50-step undo/redo, emoji picker, drag-and-drop images into the WordPress media library, per-tenant saved templates.
* Personalization tokens: `[FIRST_NAME]`, `[LAST_NAME]`, `[FULL_NAME]`, `[EMAIL]`, `[UNSUBSCRIBE_URL]`.
* Suppressions: paginated list with bounce / complaint / unsubscribe filters, manual add, CSV export. Bounces and FBL complaints are fanned out from the gateway automatically so you never have to clean a list by hand.

**Casa Webmail mailboxes (Growth and higher)**

* Self-hosted branded webmail at `webmail.onlinestorenotifications.com`. Sign in with `<your-inbox>@onlinestorenotifications.com` from any browser and read and reply to customer replies from a clean inbox.
* Use your own domain too: point your domain's MX records at `mx.sendemailtoday.io` and replies to `<your-inbox>@yourdomain.com` land in the same webmail UI, signed by the platform DKIM.
* Real Maildir storage on the Casa Mail backbone. No third-party Gmail forwarding.

**Billing and plan management**

* One-click upgrade from Free to Starter, Growth, Business, or Agency. Stripe Checkout opens in a new tab; the plugin never sees your card details.
* Paid plans are also available straight from the onboarding wizard, so you can start on the right tier from day one.
* In-WordPress quota-usage display with an "approaching cap" banner so a busy month doesn't surprise you mid-send.
* Stripe-hosted billing portal for change-card, change-plan, view-invoices, cancel.

**Built-in trust and safety**

* Sender-domain enforcement so a misconfigured WordPress install can never send under someone else's domain by accident.
* Gateway-side content review on marketing broadcasts: a separate moderation layer scans campaigns and pauses anything that looks like phishing, brand impersonation, or credential harvesting before it reaches your recipients. The gateway operator reviews flagged content and contacts you with the reason. This protects your sender reputation.

= Pricing =

* **Free**: 10,000 transactional emails per month, full quota from day one (no daily ramp), 500/day soft cap. Custom-domain authentication included. No credit card required.
* **Starter (GBP 9/month)**: 25,000 emails per month, 2,500/day cap. Custom-domain authentication.
* **Growth (GBP 29/month)**: 100,000 emails per month, Marketing Studio (contacts, segments, campaigns, visual editor, suppressions), 1 branded Casa Webmail mailbox.
* **Business (GBP 79/month)**: 500,000 emails per month, Marketing Studio, 5 mailboxes.
* **Agency (GBP 199/month)**: 2,000,000 emails per month, Marketing Studio, 25 mailboxes.

Upgrades and downgrades are entirely self-serve from Settings -> Casa Mail -> Billing. Cancellation is one click from the Stripe-hosted portal; you keep service through the end of your billing cycle.

= How it works (transactional path) =

* `pre_wp_mail` is hooked at priority 1. Each call is converted to a JSON payload and POSTed to the gateway.
* If the gateway accepts on the first POST, `wp_mail()` returns true and the message is durably enqueued upstream.
* If the gateway is unreachable on the first POST, the payload is written to a durable outbox table (`<prefix>casamail_outbox`) and a cron tick retries with 30s, 2m, 10m backoff.
* A separate transmit log table (`<prefix>casamail_sends`) records every attempt for visibility on the plugin dashboard. Rows older than 30 days are pruned automatically.

= Onboarding =

After activation, an in-WordPress wizard collects:

1. Site name, site URL, contact email address.
2. A 6-digit code emailed by the gateway to confirm the address.
3. The handle to use for your inbox (defaults to a friendly version of your site URL, e.g. `acmestore`).
4. Plan selection. Five tiers shown side-by-side (Free, Starter, Growth, Business, Agency); pick Free to get started immediately, or pick a paid tier to launch Stripe Checkout in a new tab. Either way your tenant is already provisioned so you can keep onboarding while you complete payment.
5. Where customer emails should come from: the shared Casa Mail address, or your own authenticated domain (with one-click DNS verification).

The whole onboarding is one screen with five short steps. No SMTP keys to copy, no DNS console to leave WordPress for.

= Trademark note =

This plugin is not affiliated with or endorsed by WooCommerce, Automattic, or any third party. The WooCommerce name appears only as a compatibility note (when WooCommerce is detected, the plugin's admin menu attaches under it for convenience; otherwise it lands under Settings).

== External services ==

This plugin transmits data to a third-party SMTP gateway. WordPress.org policy requires this be disclosed.

= Endpoints contacted =

The plugin makes HTTPS requests to:

* `https://api.onlinestorenotifications.com/v1/onboard/request` - during onboarding, to send your verification email.
* `https://api.onlinestorenotifications.com/v1/onboard/verify` - during onboarding, to confirm the code and provision an account.
* `https://api.onlinestorenotifications.com/v1/send` - for every `wp_mail()` call once the plugin is onboarded.
* `https://api.onlinestorenotifications.com/v1/email/domain` (GET / add / verify) - when the site administrator interacts with the Sender Domain page.
* `https://api.onlinestorenotifications.com/v1/billing/*` - checkout, billing portal, plan status. Only invoked when the site administrator interacts with the Billing page or picks a paid tier during onboarding.

The gateway is operated by CodeCasa Studios under the Casa Mail brand and runs on the OnlineStoreNotifications infrastructure. Casa Mail and OnlineStoreNotifications are sister brands of the same company; the API hostname reflects the shared backbone rather than a third-party dependency.

= Data sent =

During onboarding (one-time, before any send): site administrator email address, site name, site URL.

For each `wp_mail()` call once onboarded: sender email address, sender name, recipient email address(es), subject, message body, message headers (after stripping `From`/`To`/`Subject`/`Date`/`Message-ID`/`MIME-Version`/`Content-Type`/`Content-Transfer-Encoding`).

= Terms and privacy =

* Terms of service: https://sendemailtoday.io/terms.html
* Privacy policy: https://sendemailtoday.io/privacy.html

== Privacy ==

When activated, this plugin transmits email content (recipient, sender, subject, body, headers) to a third-party SMTP gateway for delivery. This is the plugin's only purpose. The data lifecycle is described above under "External services" and on the linked privacy policy.

The plugin also writes a `wp_add_privacy_policy_content()` block describing what is transmitted; this lets site administrators include the disclosure in the WordPress-managed privacy policy page (Settings -> Privacy).

Account deletion: a "Request account deletion" button on the plugin's Settings page emails the gateway operator. Upon confirmation, the tenant record, API key(s), domain-authentication records, and recent sending history are removed from the gateway side. The plugin uninstall additionally removes the plugin's WordPress-side options + tables.

== Installation ==

1. Upload the plugin zip via Plugins -> Add New -> Upload Plugin, or extract `casa-mail` into `wp-content/plugins/`.
2. Activate.
3. WooCommerce -> Casa Mail (or Settings -> Casa Mail if WooCommerce is not installed) launches the onboarding wizard.

The plugin requires PHP 7.4 or newer and WordPress 6.0 or newer.

== Frequently Asked Questions ==

= Does this replace existing SMTP plugins? =

Yes. The plugin hooks `pre_wp_mail` at priority 1, which runs before most SMTP plugins. For predictable behaviour, disable other mail routers (FluentSMTP, WP Mail SMTP, etc) when this plugin is active.

= What happens if the gateway is unreachable? =

Calls land in a durable retry outbox and a 60-second cron drains them with 30s / 2m / 10m backoff. After three failed retries the row is marked failed and preserved for diagnosis. `wp_mail()` always returns true (the plugin guarantees zero-loss + zero-blocking).

= How is the From: address handled? =

If the site has verified a sender domain through the plugin's Sender Domain page, the plugin rewrites the From address to `<your-inbox>@<verified-domain>` so DKIM aligns. If the caller (WooCommerce, WordPress core, etc) already supplies a From address inside the verified domain, that address is honored. A "Default From" override is also available on the Settings page.

= Where can I see what was sent? =

The Dashboard's "Recent sends" panel lists the most recent wp_mail() activity at a glance. The Logs page shows the full transmit history paginated 50 rows per page, with up to 30 days retained.

= How do I delete my account? =

Settings -> Delete my account -> Request account deletion. This emails the gateway operator who removes the tenant + API key + history within 48 hours and replies to the contact email on completion. The plugin uninstall (Plugins -> Delete) handles the WordPress-side cleanup.

= Is this affiliated with WooCommerce? =

No. WooCommerce is an Automattic trademark and this plugin is not endorsed by or affiliated with Automattic. The plugin only mentions WooCommerce as a compatibility note (the admin menu nests under WooCommerce when present, for ergonomic reasons).

== Screenshots ==

1. Dashboard - plan, monthly cap usage, outbox depth, and recent sends at a glance.
2. Sender Domain - one-click DKIM/SPF/Return-Path verification, no DNS console needed.
3. Casa Mail Logs - paginated send history with filters by date, recipient, and subject.
4. Marketing Studio campaigns - per-row sent / opens / clicks / unsubs stats.
5. Marketing Studio composer - block-based visual editor with saved templates and personalization tokens.
6. Marketing Contacts - manual add, CSV import, GDPR export, and one-click WooCommerce customer sync.
7. Casa Webmail Mailboxes - branded inboxes with per-mailbox storage and send quotas.
8. Billing - current plan card, quota usage, and one-click upgrades via Stripe Checkout.
9. Suppressions - bounce / complaint / unsubscribe filters with CSV export.

== Changelog ==

= 1.9.4 =
Adds paid-tier selection straight from the onboarding wizard (Free / Starter / Growth / Business / Agency cards side-by-side; picking a paid tier opens Stripe Checkout in a new tab while the Free tenant is provisioned for you so you're never stranded). Logs page now paginates the send history 50 rows per page (was capped at 200), and gains filters by date range, recipient (To), and subject - independent filter state from the Outbox paginator. Drops outdated IMAP/SMTP copy from the Casa Webmail upsell. Gateway side: the per-campaign first-send ramp was retired - abuse defence is now handled by the gateway content scanner, multi-account fingerprint clusterer, and per-tenant daily caps. Screenshots re-captured with tighter cropping for the directory gallery.

= 1.9.3 =
First WordPress.org release since 1.4.1. Brings the full Casa Mail platform live on the directory: in-WordPress Billing with one-click upgrades to Starter / Growth / Business / Agency (Stripe Checkout, never sees card details); Marketing Studio for Growth-and-up tenants (contacts with WooCommerce sync, segments, scheduled campaigns, block-based visual composer with saved templates and personalization tokens, per-campaign open + click reporting, suppressions UI); Casa Webmail branded mailboxes at `webmail.onlinestorenotifications.com` (Growth and up, including own-domain inbox) with real Maildir storage and reply forwarding via Postfix virtual aliases; per-tenant inbox handle (`<your-site>@onlinestorenotifications.com`) on every plan so replies route back to you instead of vanishing; sender-domain authentication wizard rewritten for non-technical users with plain-English DNS hints for Cloudflare, GoDaddy, Namecheap, and Google Domains; gateway-side content review for marketing broadcasts; full GDPR self-serve account-deletion flow. Existing 1.4.1 installs upgrade in place; the plugin re-runs onboarding once because the option-keys moved to the `casamail_` prefix.

= 1.4.1 =
Free plan moves from a 7-day daily ramp (500 to 10,000/day) to a flat 10,000 emails per month, full quota from day one. A 500/day cap stays in place. Existing free-tier accounts are backfilled automatically; nobody is downgraded.

== Upgrade Notice ==

= 1.9.4 =
Adds paid-tier selection during onboarding, log pagination + filters (by date, recipient, subject), and tightens the Casa Webmail upsell copy. No data migration required.

= 1.9.3 =
First major release on WordPress.org since 1.4.1. Adds Marketing Studio, branded Casa Webmail mailboxes, in-WordPress Billing, WooCommerce customer sync, and a rewritten sender-domain wizard. Existing installs re-run onboarding once because the option-keys moved to the `casamail_` prefix in 1.4.0.

= 1.4.1 =
Free plan moves to a flat 10,000 emails per month with full quota from day one. No data migration required.
