=== Neuedaten Privacy Mail Log ===
Contributors: bastianschwabe
Tags: mail log, email log, gdpr, dsgvo, privacy
Requires at least: 6.7
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Mail logging with anonymization and GDPR-friendly retention. Log every email your site sends — and decide how long personal data is kept.

== Description ==

Privacy Mail Log records every email sent through `wp_mail()`: recipients, subject, body, attachments (file names only), and whether the send succeeded or failed. Unlike most mail loggers, it treats the log itself as what it is — a growing collection of personal data — and gives you the tools to keep it small.

You decide per field whether the recipient name, the recipient email address, the subject and the body are anonymized: never, after a retention period, or immediately when the entry is written. Immediately anonymized data never reaches the database at all. A second retention stage deletes old entries completely. Anonymization is irreversible.

**Features**

* Logs every email sent through `wp_mail()`, including failed sends with their error message
* Log view with search, status filter and bulk delete; HTML emails are rendered in a sandbox that blocks scripts and forms
* Per-field anonymization: recipient name, recipient email address, subject and body — each set to never, after the retention period, or immediately
* Metadata-only mode: set the body to "Immediately" and the message content is never stored
* Three replacement styles for email addresses: a plain placeholder, a stable hash (still countable and searchable), or keeping just the domain
* Two-stage retention via WP-Cron: anonymize after a number of days, delete completely after a longer period
* Integrates with the WordPress privacy tools: personal data exports include matching log entries, and erasure requests anonymize them
* Test email screen to verify that logging works on your site
* Attachments are stored as file names only, never as files
* No dependencies, no external requests, no tracking

**Privacy**

The log stores personal data: email addresses, names, subjects and message bodies of the emails your site sends. What is stored and for how long is under your control:

* Fields set to "Immediately" are anonymized before the entry is written, so that data never reaches the database.
* The retention cron anonymizes entries after a configurable number of days (default 30) and deletes them completely after a longer period (default 90 days).
* Personal data export requests (Tools → Export Personal Data) include matching log entries; erasure requests (Tools → Erase Personal Data) irreversibly anonymize them while the send record itself remains.
* Attachments are recorded as file names only. The plugin makes no external requests.

Privacy Mail Log is a tool, not a compliance guarantee. Whether your use of it complies with the GDPR/DSGVO or any other regulation depends on your configuration, your retention periods and your processes as the site operator. This is not legal advice.

**For developers**

* `neuedaten_pml_logged` — action fired after an email has been written to the log, with the entry id and the stored values
* `neuedaten_pml_settings` — filter the resolved plugin settings
* `neuedaten_pml_capability` — filter the capability required for all plugin screens (default `manage_options`)
* `neuedaten_pml_retention_batch_size` — filter how many entries each retention stage processes per cron run (default 500)

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install it through the Plugins screen.
2. Activate the plugin. From now on every email sent through `wp_mail()` is logged.
3. Go to **Mail Log → Settings** and choose your anonymization and retention periods.
4. Use **Mail Log → Test Email** to send yourself a test email and check the log entry.

== Frequently Asked Questions ==

= Does it capture emails sent by SMTP plugins? =

Emails are captured through the WordPress mail hooks (`pre_wp_mail`, `wp_mail_succeeded`, `wp_mail_failed`). SMTP plugins that build on `wp_mail()` are captured. A plugin that replaces the mail function entirely without firing these hooks bypasses the log.

= What does the "Pending" status mean? =

The email was handed over for sending, but neither the success nor the failure signal arrived — typically because another plugin took over the delivery and did not report back. The email may well have been sent.

= What happens on a personal data erasure request? =

All log entries addressed to the requested email address are irreversibly anonymized: recipient name and address, subject and body are replaced. The entry itself remains, so send statistics stay intact while no personal data is left.

= How do I stop the body from being stored at all? =

Set **Body** to *Immediately* on the settings screen. The message content is then replaced before the entry is written and never reaches the database — only metadata is logged.

= Is anonymization reversible? =

No. The original values are overwritten in the database. There is no way to restore them.

= Does using this plugin make my site GDPR compliant? =

No plugin can promise that. Privacy Mail Log gives you the tools — configurable retention, per-field anonymization, integration with the WordPress privacy tools — but compliance depends on your configuration and your processes. When in doubt, ask a professional.

== Screenshots ==

1. The mail log with search, status filter and bulk actions.
2. The detail view of a logged email, rendered in a sandbox.
3. The settings screen with per-field anonymization and retention periods.
4. The test email screen.

== Changelog ==

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.0.0 =
Initial release.
