=== tlloancy Outgoing Mail Inbox ===
Contributors: tlloancy
Donate link: https://donorbox.org/wordpress-plugins
Tags: inbox, email, wp_mail, contact form, woocommerce
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Turns the WordPress mail log into an inbox: highlight notices the site sent to itself, and reply to the real person.

== Description ==

When a visitor fills in your contact form, you do not really receive a mail *from them*. Your own site builds an outgoing mail containing their message — often sent from your site address **to** your site address — and the visitor’s real address is hidden in the Reply-To header or in the order. Hit “reply” in a normal mail program and you write to yourself.

**tlloancy Outgoing Mail Inbox** captures those outgoing mails (the same `wp_mail()` source WP Mail Logging uses), files the ones meant for you like received mail, and makes Reply go to the actual visitor or customer:

* **For you** — To matches an owner address (admin email, your reply From, or extra addresses you list). These rows are highlighted.
* **Sent** — everything else the site mailed (customer confirmations, password resets…), including background notices.
* **Reply** — sends a new message **to the visitor or customer**, From the site mailbox. It does **not** resend the original mail to the same To (that would write to yourself).

Background noise is filed automatically, in every language. The plugin recognizes system mail by **who sends it** (the WordPress auto-updater, language packs, the WP Mail SMTP weekly summary), never by the subject text:

* Successful auto-update notices and mailer digests are marked **System** and filed under Sent — they no longer bury real messages in For you.
* A **failed** update or a recovery-mode crash becomes a highlighted **Site alert** in For you, with the PHP error details pulled out of the mail (WordPress 7.2 adds the last fatal error to update-failure mails; recovery mails have carried it since 5.2).

**AI, the WordPress way.** With the WordPress AI plugin and a connector key, a **Draft a reply with AI** button appears on the message screen. It writes a reply in the language of the original mail; nothing is sent until you click Send reply. Prompts only go to the connector checked for this plugin under Settings → Connectors → Approvals — never to an unapproved one. Developers can plug AI (or plain PHP rules) into the sorting itself through the `inbox_bridge_classify` filter and the `inbox_bridge_ai_prompt()` helper.

The reply address is taken from the Reply-To header when it is not the site, then from a WooCommerce order number in the subject/body, then from the first non-owner email in the message. You can edit it before sending.

Replies go through `wp_mail()`. If **WP Mail SMTP** (or another mailer) is already talking to Brevo, the reply is authenticated on your domain like any other site mail.

This is not a mailbox for people who write directly to `you@yourdomain.com` from Gmail. Those never pass through `wp_mail()`.

Not affiliated with inboxbridge.io, Proton Mail Bridge, or other products named Inbox Bridge.

Step-by-step guides: `docs/USER-GUIDE.md` (English) and `docs/MODE-DEMPLOI.md` (French).

== Installation ==

1. Upload the `tlloancy-outgoing-mail-inbox` folder to `/wp-content/plugins/`.
2. Activate **tlloancy Outgoing Mail Inbox**.
3. Open **Inbox** in the admin menu.
4. Under **Inbox → Settings**, set the reply From address (your domain mailbox) and the owner addresses that mean “this mail is for me”.
5. Keep WP Mail SMTP (or equivalent) configured if you already use it.

== Frequently Asked Questions ==

= Is this WP Mail Logging? =

Same raw material: every `wp_mail()` call. Different job. WP Mail Logging is a send log with **Resend**. tlloancy Outgoing Mail Inbox is an inbox: **For you** vs **Sent**, and **Reply** to the human.

= Why is a contact-form mail “outgoing”? =

Because WordPress generated it. The visitor submitted a form; the site mailed you. In the inbox that row is **For you**.

= Who receives my reply? =

The visitor or customer — Reply-To, billing email on an order, or an address found in the body. Never the site From, unless you type that on purpose.

= Is this related to inboxbridge.io or Proton Mail Bridge? =

No. This is an independent plugin by tlloancy. It only logs WordPress `wp_mail()` into wp-admin. It is not affiliated with those products.

= Which From address is used for replies? =

The default is the WordPress admin email (Settings → General). You can change it under Inbox → Settings. Replies still go through `wp_mail()`. If WP Mail SMTP has **Force From Email** enabled, that SMTP From address is the one recipients see.

= Do I need the Cloudflare worker / Hotmail setup? =

No. This plugin only sees mail WordPress sends.

= Do contact forms need a special setup? =

Most already set Reply-To to the visitor. If they do not, add the visitor email as Reply-To, or type the address on the reply form.

= Will password resets show up? =

Yes, under **Sent** (and **All**). They are not highlighted unless they were addressed to an owner mailbox.

= Why are “plugins were automatically updated” mails not in For you? =

They are addressed to you, but nobody is on the other side — there is nothing to reply to. The plugin recognizes the WordPress auto-updater (and similar background senders) by the sending code, not by the subject, so this works in every language. Successful updates are filed under Sent as **System**; a failed update or a crash stays in For you as a red **Site alert** with the error details.

= How does the AI draft work, and which connector does it use? =

Install the WordPress AI plugin and add a connector key, then check this plugin under Settings → Connectors → Approvals. The Draft button on a message asks the approved connector for a reply in the language of the original mail and puts it in the editor — you review and send. The approval matrix is re-read on every request, so switching the checked connector takes effect immediately. If no connector is checked, you get a clear error instead of a silent call to an unapproved one.

= Can AI re-sort the inbox? =

The classification of every logged mail passes through the `inbox_bridge_classify` filter (folder, unread state, category, reply target). Combine it with `inbox_bridge_ai_prompt()` — which honors the same connector approvals — to build an AI triage, or use plain PHP rules.

== Changelog ==

= 1.1.0 =
* New: language-independent triage. Auto-update and digest mails are recognized by sender (core updater filters, call stack), filed under Sent as System — For you keeps only real messages.
* New: Site alerts. Failed auto-updates and recovery-mode mails stay in For you, highlighted in red, with the PHP fatal error extracted (ready for the WordPress 7.2 update-failure mails).
* New: Draft a reply with AI, pinned to the connector approved for this plugin under Settings → Connectors → Approvals; clear error when none is checked.
* New: `inbox_bridge_classify` filter and `inbox_bridge_ai_prompt()` helper so AI or custom rules can re-file any logged mail.
* Improved: list badges (Site alert / System), alert panel on the message screen, refreshed row styles.

= 1.0.0 =
* First release: wp_mail log, For you / Sent folders, highlighted owner notices, reply to the correspondent.

== Upgrade Notice ==

= 1.1.0 =
For you stops collecting auto-update noise; failed updates become red alerts with error details; optional AI reply drafts via approved connectors.

= 1.0.0 =
Initial release.
