=== Groundmail ===
Contributors: groundmail
Tags: email, wp_mail, transactional email, email api, woocommerce
Requires at least: 5.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

Send every WordPress and WooCommerce email through the Groundmail email API: password resets, order emails, notifications and more.

== Description ==

Groundmail sends your site's email through the [Groundmail](https://groundmail.dev/?utm_source=wordpress.org&utm_medium=plugin_readme&utm_campaign=groundmail-wordpress) email API instead of your web server's mail function, so password resets, new account emails, comment notifications and order emails reach the inbox and you can see what happened to each one.

The plugin hooks into `wp_mail()`, the function WordPress and almost every plugin use to send email. Nothing else on your site has to change.

**WooCommerce works automatically.** WooCommerce sends order, account and admin emails with `wp_mail()`, so once the plugin has an API key every WooCommerce email goes through Groundmail too. The same goes for contact form, membership and booking plugins that use `wp_mail()`.

= Features =

* Sends over HTTPS with the Groundmail API, so it works on hosts that block SMTP ports.
* HTML and plain-text email, CC, BCC and Reply-To.
* Attachments, such as PDF invoices, and inline images.
* Custom headers from other plugins are kept.
* Set a default From email and name, or force them for every email.
* Keep the API key in the database, or in `wp-config.php` with the `GROUNDMAIL_API_KEY` constant.
* Send a test email from the settings page.
* Optional send log of the last 50 emails: recipients, subject and result, never the content.
* Works with the filters and hooks other plugins use to change email (`wp_mail_from`, `wp_mail_from_name`, `wp_mail_content_type`, `phpmailer_init`, `wp_mail_failed` and `wp_mail_succeeded`).

Until you add an API key, the plugin does nothing and WordPress sends email the way it did before.

= What you need =

A Groundmail account, a domain verified in Groundmail and an API key. The free plan includes 3,000 emails a month with no time limit. [Create a free account](https://app.groundmail.dev/signup?utm_source=wordpress.org&utm_medium=plugin_readme&utm_campaign=groundmail-wordpress).

== External services ==

This plugin connects to the Groundmail API at `https://api.groundmail.dev` to send your site's email. It contacts Groundmail only after you add a Groundmail API key, and makes two kinds of requests:

* **Sending an email.** Every time WordPress or a plugin sends an email with `wp_mail()`, the plugin sends that email to `https://api.groundmail.dev/emails`: the sender's address and name, the recipients (To, CC, BCC, Reply-To), the subject, the content, any attachments and custom headers, plus your API key to identify your account. Groundmail delivers it to the recipients.
* **Checking your API key.** When you save a new API key on Settings → Groundmail, the plugin asks `https://api.groundmail.dev/emails?limit=1` whether Groundmail accepts it. Only the key is sent.

Each request also says which plugin and WordPress version made it. Nothing else is sent: no tracking, analytics or data about your visitors beyond the emails your site sends to them. Without an API key the plugin makes no requests.

Groundmail is provided by Groundmail: [Terms of service](https://groundmail.dev/legal/terms/), [Privacy policy](https://groundmail.dev/legal/privacy/).

== Installation ==

1. Install and activate the plugin from Plugins → Add New, or upload the `groundmail` folder to `/wp-content/plugins/`.
2. In Groundmail, verify the domain you send from and create an API key under API Keys. A send-only key is enough.
3. In WordPress, go to Settings → Groundmail and paste the API key. Or add it to `wp-config.php` instead:

    define( 'GROUNDMAIL_API_KEY', 'gm_your_key' );

4. Set the From email to an address on your verified domain, such as `wordpress@yourdomain.com`.
5. Send a test email from the same page. To check the connection without emailing a real inbox, send it to `delivered@simulator.groundmail.dev`.

For WooCommerce, also set WooCommerce → Settings → Emails → "From" address to an address on your verified domain, or turn on Force From.

== Frequently Asked Questions ==

= Does it work with WooCommerce? =

Yes. WooCommerce sends its emails with `wp_mail()`, so they go through Groundmail with no extra setup. Make sure the WooCommerce "From" address is on a domain you verified in Groundmail, or turn on Force From.

= What happens if I remove the API key? =

The plugin steps aside and WordPress sends email the way it did before the plugin was installed.

= What happens if Groundmail can't send an email? =

`wp_mail()` returns false and WordPress fires the `wp_mail_failed` action with Groundmail's error, as it does for any failed email, so plugins that retry or report failures keep working. With the send log on, the error also shows on Settings → Groundmail.

= Which From address can I use? =

An address on a domain you verified in Groundmail. Set it as the From email on Settings → Groundmail. Emails that set their own sender keep it, unless you turn on Force From.

= Can I keep the API key out of the database? =

Yes. Define `GROUNDMAIL_API_KEY` in `wp-config.php`. The settings page then shows only the last four characters of the key.

= Where can I see whether an email was delivered? =

On the Emails page of the Groundmail dashboard, with its delivery status, opens and bounces. The plugin's send log shows whether Groundmail accepted each email and its id.

= Is there an SMTP option? =

This plugin uses the Groundmail API over HTTPS. If you'd rather use SMTP with another plugin, see the [WordPress guide](https://docs.groundmail.dev/integrations/wordpress?utm_source=wordpress.org&utm_medium=plugin_readme&utm_campaign=groundmail-wordpress).

== Changelog ==

= 1.0.0 =
* First release: send `wp_mail()` through the Groundmail API, with attachments, inline images, CC, BCC, Reply-To, custom headers, From settings, a test email and an optional send log.

== Upgrade Notice ==

= 1.0.0 =
First release.
