=== Resonanz Email Rerouting ===
Contributors: resonanzdigital
Tags: email, rerouting, testing, development, staging
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 1.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Reroute WordPress emails to a test address per environment so testing never mails real users. Optional logging and settings import/export.

== Description ==

Resonanz Email Rerouting makes testing websites safer by rerouting outgoing emails to a specific address based on the current environment (local, development, staging, production), as defined by the `WP_ENVIRONMENT_TYPE` constant in your `wp-config.php` file.

= Features =
* Reroute emails based on `WP_ENVIRONMENT_TYPE`.
* Enable or disable email rerouting on a per-environment basis.
* Add domains to a whitelist to avoid rerouting mail sent to those domains.
* Add one or more email addresses to which emails should be rerouted.
* Grant different user roles access to the plugin settings.
* Add a prefix to the subject line of rerouted emails.
* Append a message to the body of rerouted emails.
* Display a notification to the logged-in user when an email has been rerouted.
* Enable or disable simple email logging, including a retention policy.
* Easily export and import settings in JSON format.
* Works with Gravity Forms and Contact Form 7.

== Installation ==

1. Configure the environment variable in `wp-config.php` (see FAQ below).
2. Upload the entire `resonanz-email-rerouting` folder to the `/wp-content/plugins/` directory.
3. Activate the plugin through the 'Plugins' menu in WordPress.

== Frequently Asked Questions ==

= How do I set the environment variable? =

You can set the environment variable in your `wp-config.php` file. Add a line like the following:

`define('WP_ENVIRONMENT_TYPE', 'local');`

For further information, see the WordPress documentation: https://developer.wordpress.org/apis/wp-config-php/#wp-environment-type

= Does this plugin work with other email related plugins? =

We cannot guarantee that this plugin will function as expected if you use other email-related plugins.

If you have a plugin that makes use of SMTP, you should probably disable it for this plugin to work correctly.

If you encounter specific issues, please let us know.

= Where can I find further help? =

If you require assistance, feel free to email us at wordpress@resonanz-digital.at.

== Changelog ==

= 1.5.0 =
* Hardened sanitization of saved settings: role permission keys are now validated against the roles WordPress actually offers.
* Settings import now runs through the same sanitizer as the settings form, so imported files can no longer store unsanitized values.
* Prefixed the AJAX, admin-post and log-purge action names to avoid collisions with other plugins.
* Prefixed the email log meta keys. Existing logs are migrated automatically on upgrade.
* Added nonce verification to both AJAX endpoints.
* Fixed settings import rejecting every file. The uploaded file is now identified correctly.
* Fixed settings import failing on Windows servers because the upload path was altered before use.
* Renamed an internal helper that shadowed WordPress core's `sanitize_email()`.
* Updated "Tested up to" for WordPress 7.1.

= 1.4.0 =
* Hardened input handling and output escaping throughout the plugin (Plugin Check compliance).
* Fixed per-environment settings (whitelisted domains and reroute addresses) not being sanitized on save.
* Fixed role capabilities lagging one save behind when permissions were changed.
* Fixed the bundled German translation not loading (translation files renamed to match the text domain).
* Added cleanup on deactivation (scheduled event) and uninstall (options, capability, and logged data).
* Switched to safe redirects and `gmdate()`, and added a `readme.txt`.

= 1.3.1 =
* Fixed rerouted emails crashing when `wp_mail()` recipient, sender, subject, or message values were passed in non-string formats.

= 1.3.0 =
* Validation of entered email addresses in the WordPress backend.
* Performance optimizations.

= 1.2.5 =
* Fixed a minor namespace issue that was causing an error when purging logs.

= 1.2.4 =
* Make sure post slug is not empty.
* Some other minor code improvements.

= 1.2.3 =
* Added information to allow the plugin to be updated via Git Updater.

= 1.2.2 =
* First public release of the plugin.
