=== Lettermint ===
Contributors: lettermint
Tags: email, smtp, transactional, lettermint, wp-mail
Requires at least: 6.4
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.5.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Professional email delivery for WordPress. Seamlessly integrates with wp_mail() to send emails through Lettermint.

== Description ==

[Lettermint](https://lettermint.co) is a professional email delivery plugin that seamlessly integrates with WordPress's built-in wp_mail() function to send transactional emails through the Lettermint email service. Based in Europe, Lettermint provides reliable email delivery with excellent deliverability rates.

= Features =

* **Seamless Integration**: Works with wp_mail() - no code changes required
* **Europe-based Service**: GDPR compliant email service based in Europe
* **Easy Configuration**: Simple setup with just your API token and sender email
* **Comprehensive Logging**: Optional email activity logging with detailed information
* **Conflict Detection**: Automatically detects and warns about conflicting email plugins
* **Test Email**: Built-in test email functionality to verify your setup
* **Configure via wp-config**: Set any option with a constant in wp-config or an environment variable, not just the dashboard
* **WP-CLI Support**: Check your API token and send test emails from the command line with `wp lettermint`

= How It Works =

1. Install and activate the Lettermint plugin
2. Get your API token from [Lettermint Dashboard](https://app.lettermint.co/projects)
3. Configure your settings in WordPress admin under Settings > Lettermint
4. All WordPress emails will automatically be sent through Lettermint

= Requirements =

* WordPress 6.4 or higher
* PHP 7.4 or higher
* Lettermint account and API token

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/lettermint` directory, or install the plugin through the WordPress plugins screen directly
2. Activate the plugin through the 'Plugins' screen in WordPress

Then set it up in one of two ways:

= Option 1: Configure in the dashboard =

1. Go to Settings > Lettermint
2. Enter your Lettermint API token
3. Adjust the sender address and other options as needed
4. Test your configuration using the built-in test email feature

= Option 2: Configure with constants or environment variables =

Prefer to keep your settings out of the database? Define them as PHP constants in wp-config, or as environment variables. This suits staging and production setups and config-as-code deployments.

`define( 'LETTERMINT_API_TOKEN', 'lm_...' );`

You can also add a constant from the command line with WP-CLI, which edits wp-config for you:

`wp config set LETTERMINT_API_TOKEN lm_...`

A constant takes precedence over an environment variable, which takes precedence over anything saved in the dashboard. Settings defined this way are shown as read-only on the settings screen.

Available names:

* `LETTERMINT_API_TOKEN` — your Lettermint API token
* `LETTERMINT_FROM_EMAIL` — sender email address
* `LETTERMINT_FROM_NAME` — sender name
* `LETTERMINT_FORCE_EMAIL` — use the sender email for all outgoing mail (`1`/`0`)
* `LETTERMINT_FORCE_FROM_NAME` — use the sender name for all outgoing mail (`1`/`0`)
* `LETTERMINT_FORCE_HTML` — always send emails as HTML (`1`/`0`)
* `LETTERMINT_ROUTE_SLUG` — custom route slug
* `LETTERMINT_TAG` — tag applied to all emails
* `LETTERMINT_ENABLE_LOGS` — enable activity logging (`1`/`0`)

Boolean settings accept `1`/`0` as well as `true`/`false`.

= Verify with WP-CLI =

If you use WP-CLI, the plugin adds a `lettermint` command.

Check that your API token is valid:

`wp lettermint status`

Send a test email through Lettermint to confirm delivery:

`wp lettermint test you@example.com`

== Configuration ==

= Required Settings =

* **API Token**: Your Lettermint API token from your project

= Optional Settings =

* **From Email Address**: Custom sender email address (uses WordPress default if empty)
* **Force Email Address**: Override sender addresses set by plugins with your configured email
* **Enable Logs**: Keep track of email activities and API responses

== Frequently Asked Questions ==

= Where do I get my API token? =

You can get your API token from the [Lettermint Dashboard](https://app.lettermint.co/projects) in your project settings.

= Will this work with my existing WordPress emails? =

Yes! The plugin seamlessly integrates with WordPress's wp_mail() function, so all plugins and themes that send emails will automatically use Lettermint.

= What happens if there's a conflict with another email plugin? =

The plugin automatically detects common email plugins and shows a warning if conflicts are detected. You should deactivate other email plugins to avoid conflicts.

= Can I test if emails are working? =

Yes! The plugin includes a built-in test email feature in the Settings > Lettermint > Test Email tab.

= Is logging required? =

No, logging is optional but recommended during setup to help troubleshoot any issues. You can disable it once everything is working properly.

= Can I configure the plugin with constants or environment variables? =

Yes. Every setting can be supplied with a PHP constant or an environment variable instead of the settings screen, which keeps secrets and environment-specific values out of the database. See the Installation section for the available names.

= Does the plugin support WP-CLI? =

Yes. The plugin adds a `wp lettermint` command with two subcommands: `wp lettermint status` checks that your API token is valid, and `wp lettermint test` sends a test email.

== Screenshots ==

1. General settings page with API token and sender email configuration
2. Test email functionality to verify your setup
3. Comprehensive logging with detailed email activity
4. Conflict detection warning for other email plugins

== External Services ==

This plugin uses an external service to deliver transactional emails via the Lettermint API.

- **Service Name**: Lettermint API (https://lettermint.co)
- **Purpose**: This service is used to send transactional emails generated by WordPress (e.g. password resets, contact form notifications, WooCommerce emails, etc.) through the Lettermint email infrastructure.
- **What Data Is Sent**: Each time an email is sent via WordPress, the following data is sent to the Lettermint API:
  - Email recipient(s)
  - Subject
  - Email content (HTML and plain text)
  - Sender email address
  - Headers (optional)
- **When Is Data Sent**: Data is only sent when an email is triggered by WordPress and the plugin is active and properly configured.
- **Where**: All data is sent to Lettermint’s API endpoint: `https://api.lettermint.co`
- **Terms and Policies**:
  - [Lettermint Terms and Conditions](https://lettermint.co/terms-of-service)
  - [Lettermint Privacy Policy](https://lettermint.co/privacy-policy)

The plugin only communicates with Lettermint's servers when sending an email and does not transmit or collect any other data beyond what is needed to send the email.

== Changelog ==

= 1.5.0 =
* Added WP-CLI support: `wp lettermint status` checks that your API token is valid, and `wp lettermint test` sends a test email
* Any setting can now be configured with a constant in wp-config or an environment variable
* Logs are now stored in a dedicated `{prefix}_lettermint_logs` table with an indexed `created_at` column, replacing the previous autoloaded option
* Fixed memory exhaustion caused by base64-encoded attachment payloads in log entries; new entries store filename and size only
* Existing log entries are cleared on upgrade to immediately relieve memory pressure; the old `lettermint_logs` option is removed
* Logging defaults to off for new installs; the upgrade preserves logging for installs that previously had it enabled
* Plugin options and the logs table are removed on uninstall
* Updated Dutch translations
* Bumped minimum WordPress version to 6.4

= 1.4.3 =
* Tested up to WordPress 7.0
* Updated admin header design to match new Lettermint dashboard branding

= 1.4.2 =
* Added WordPress and plugin version to test email footer
* Added dismissible notice on logs page explaining Success status

= 1.4.1 =
* Fixed RFC 5322 compliance: from name now properly quoted for special characters (commas, ampersands, etc.)
* Fixed HTML entities in blog name being sent as encoded text (e.g., &amp; instead of &)

= 1.4.0 =
* Plugin now sends all emails through Lettermint when API token is configured
* From Email Address is now optional (uses WordPress default when empty)
* From Name is now optional (uses site name when empty)
* Force Email Address and Force Name now work independently of each other
* Simplified setup: just add your API token and you're ready to go

= 1.3.1 =
* Fixed sender email now applies even when Force Email Address is disabled (allows plugins to override)
* Improved description text for Force Email Address option
* Fixed From email field placeholder to show WordPress default email instead of admin email

= 1.3.0 =
* Added API Token Test button to validate token before saving
* Added Tag setting in Advanced Settings to tag all emails from a site
* Added "From" column in logs table
* Logs now capture all WordPress emails, including those sent via the default mailer
* Logs are automatically cleared when disabling logging
* Updated Dutch translations

= 1.2.1 =
* Added "Force HTML" option in Advanced Settings for sites where HTML emails are sent as plain text

= 1.2.0 =
* Fixed HTML emails not rendering correctly
* Improved logs: added Subject and To columns for better overview
* Added View Error button to see detailed error information in a modal
* Updated Dutch translations

= 1.1.0 =
* Added "View Details" button in logs table linking to Lettermint dashboard
* Improved interface
* Added advanced settings section with custom route support

= 1.0.1 =
* Added Dutch translation support
* Added sender name functionality with force override option

= 1.0.0 =
* Initial release
* Seamless wp_mail() integration
* API token and sender email configuration
* Test email functionality
* Comprehensive logging system
* Plugin conflict detection
* Professional WordPress admin interface
* GDPR compliant Europe-based email service

== Upgrade Notice ==

= 1.5.0 =
Important fix for installs that send emails with attachments: addresses memory exhaustion caused by attachment payloads being stored in logs. Logs now live in a dedicated database table; existing log entries are cleared on upgrade. Now requires WordPress 6.4+.

= 1.4.0 =
Important: Emails are now sent through Lettermint as soon as your API token is configured. The "Force Email Address" option now only controls whether to override the sender email. If you previously had an API token set but Force Email Address disabled, your emails will now be sent through Lettermint.

= 1.3.1 =
Fixed sender email behavior and improved UI descriptions.

= 1.3.0 =
New features: API Token Test button, Tag setting for email filtering, improved logging that captures all WordPress emails.

= 1.2.1 =
Added "Force HTML" option for sites where HTML emails are incorrectly sent as plain text.

= 1.2.0 =
Fixed HTML emails from WooCommerce and other plugins not rendering correctly.

= 1.1.0 =
Added "View Details" button in logs table linking to Lettermint dashboard, improved interface, and added advanced settings section with custom route support.

= 1.0.1 =
Added Dutch translation support and sender name functionality.

= 1.0.0 =
Initial release of the Lettermint plugin for WordPress.