=== Bentostudio Mail ===
Contributors: gunther9966
Tags: smtp, email, mail-log, email-log, gdpr
Requires at least: 6.2
Tested up to: 7.1
Stable tag: 2.0.4
Requires PHP: 8.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Modular SMTP configuration, privacy-friendly mail logging, and role-based access control for WordPress - with no external services.

== Description ==

Bentostudio Mail is a modular WordPress mail management solution built entirely on native WordPress APIs - no external dependencies, no SaaS account required.

The plugin deliberately focuses on the core functions of SMTP sending and mail logging. For SMTP configuration, it provides a plain SMTP interface only, without pulling in additional third-party service dependencies. The two core areas - SMTP settings and mail logging - can also be used independently of each other: for example, you can configure SMTP sending only, without logging any mails, or use the mail log without changing anything about the SMTP route.

**SMTP Sending**

* Simple configuration of the SMTP sending method directly in the WordPress backend.
* Technically thorough two-step connection diagnostics: a raw socket probe (`fsockopen()`) followed by a full PHPMailer handshake with a captured debug transcript.
* Send a live test email to confirm end-to-end delivery.
* Detects other active third-party SMTP plugins and notes that, due to hook load order, its own settings take precedence for actual sending.

**Mail Log & Statistics**

* Stores sent emails (similar in principle to Flamingo).
* Privacy-friendly by design: data is stored exclusively in your own server's local database - no external services or cloud connections involved.
* Freely configurable retention by entry count and/or age, helping you apply the data minimization / storage limitation principle required by data protection laws such as GDPR (EU/UK), CCPA/CPRA (California), LGPD (Brazil), PIPA (South Korea), PDPA (Singapore), and DPDPA (India).
* Dashboard with live SMTP status, delivery statistics, and an activity overview.
* Logs failed delivery attempts.
* Identifies the sending source in the statistics (e.g. Contact Form 7, WordPress system notifications).

**Role-Based Access Control**

* Assign access to the statistics and SMTP settings with a single click.
* Uses WordPress's existing user roles (Editor, Shop Manager, etc.) - no separate permission system required.
* Four granular capabilities, one per module page.

**Other Technical Features**

* Clean uninstall: removes the database table and every `wp_options` entry the plugin ever wrote.

== Installation ==

1. Upload the `bentostudio-mail` folder to `/wp-content/plugins/`.
2. Activate the plugin through **Plugins > Installed Plugins**.
3. Navigate to **Bentostudio Mail > SMTP Settings** and enter your SMTP credentials.
4. Click **Test Connection** to verify server reachability via a socket probe and PHPMailer handshake.
5. Click **Send Test Email** to confirm end-to-end delivery.

== Frequently Asked Questions ==

= Does this plugin store SMTP passwords securely? =

SMTP credentials are stored in `wp_options` in plain text, the same way all core WordPress options are stored. Restrict database access and use application-specific passwords where your provider supports them.

= Which encryption modes are supported? =

TLS (STARTTLS on port 587), SSL (implicit TLS on port 465), and none (unencrypted, not recommended).

= Does the plugin detect other active SMTP plugins? =

Yes. Bentostudio Mail detects when other SMTP plugins are active and flags this to the user. It does not automatically disable or modify those plugins' settings - however, due to hook load order, its own `phpmailer_init` configuration is the one that ends up controlling actual mail delivery.

= Does this plugin help with compliance with data protection laws like GDPR or CCPA? =

All mail logs are stored exclusively in your own server's local database - no data is transmitted to external services. The freely configurable retention period and entry limit help you apply the data minimization principle required by GDPR/DSGVO, CCPA/CPRA, LGPD, PIPA, PDPA, and DPDPA, among others. Ensuring your privacy policy and its legal basis are compliant remains your responsibility.

= Can I grant SMTP or statistics access to editors or shop managers? =

Yes. In **Plugin Setup > Role Assignment** you can assign any registered WordPress role to each of the four access capabilities independently.

= What happens to my data when I uninstall the plugin? =

Clicking **Delete** in the plugin list runs `uninstall.php`, which drops the `{prefix}bentostudiomail_mail_log` table and removes all plugin options from `wp_options`. No data is left behind.

== Screenshots ==

1. Overview dashboard with live SMTP status, delivery statistics, and a recent mails table.
2. Statistics page showing sent mails, success rate, and errors, plus the full mail log view.
3. SMTP settings page with connection test and debug view.
4. Plugin setup - role assignment for statistics and SMTP access.
5. Plugin setup - statistics settings (enable/disable, delete logs, retention count and period).

== Changelog ==

= 2.0.4 =
* Performance: Changed age-based log retention to run efficiently via a daily WP-Cron job instead of on every page load. The cleanup is also triggered instantly when the settings limit changes.
* Fix: Improved Multisite compatibility for the mail log database table and limit enforcement.

= 2.0.3 =
* Fix: Age-based log retention (Max. storage duration) now correctly deletes entries older than the configured number of days.
* New: The SMTP Settings page now displays the currently active WordPress mail sending method (SMTP, PHP mail, Sendmail, etc.) with full configuration details, detected live via `phpmailer_init`.
* Change: "Max. storage duration" now defaults to 14 days when left empty — same behaviour as "Max. number of entries" (default: 10,000). Saving 0 or an empty field applies the 14-day default.

= 2.0.2 =
* Improved formatting in the mail preview.

= 2.0.1 =
* Consolidated update - see previous releases.

= 1.0.18 =
* Initial public release.
* Modular architecture with four built-in modules: Overview, Statistics, SMTP Settings, Plugin Setup.
* Role-based capability system with per-module granularity.
* SMTP connection tester with raw socket probe and full PHPMailer debug transcript.
* Detection of active third-party SMTP plugins.
* Mail log with configurable entry-count and age-based retention limits.
* AJAX detail modal with sandboxed email body preview.
* Clean uninstall script.

== Upgrade Notice ==

= 2.0.4 =
Performance and Multisite improvements: log retention is now efficiently processed via WP-Cron.

= 2.0.3 =
Bug fix: age-based log retention now works correctly. Upgrade recommended if you use the "Max. storage duration" setting.

= 2.0.2 =
Minor improvement: refined formatting in the mail preview.

= 2.0.1 =
Consolidated update - no known breaking changes.