# OpenCart email with Groundmail

Send OpenCart store email through Groundmail by switching OpenCart's mail engine to SMTP and pointing it at the Groundmail SMTP relay. Order confirmations, order status updates, customer account and password reset emails, and admin alerts then go out from your own domain. These steps cover OpenCart 4.

---

## Prerequisites

- A Groundmail account with a [verified sending domain](https://docs.groundmail.dev/domains).
- An SMTP credential: in the Groundmail dashboard, open **SMTP** and choose **Create SMTP credential**. The password (`gmsmtp_…`) is shown once, so copy it. See [SMTP relay](https://docs.groundmail.dev/smtp).
- Admin access to OpenCart, with permission to edit store settings.

Everything the store sends through the relay goes out as transactional email, so use it for order, account and notification email. Send opt-in newsletters through the [API](https://docs.groundmail.dev/emails) with `category: "newsletter"` once your account is approved, and never send cold email.

---

## Set the mail engine

1. In the OpenCart admin, go to **System**, then **Settings**, and edit your store.
2. Open the **Mail** tab and fill in:

| OpenCart field | Value |
|----------------|-------|
| Mail Engine | `SMTP` |
| SMTP Hostname | `tls://smtp.groundmail.dev` |
| SMTP Username | `groundmail` |
| SMTP Password | Your SMTP credential (`gmsmtp_…`) |
| SMTP Port | `587` |
| SMTP Timeout | `5` or more |

3. Leave **Mail Parameters** empty, and click **Save**.

The `tls://` prefix makes OpenCart upgrade the connection with STARTTLS, which is what the relay expects on port 587. Don't use `ssl://`, which is for port 465. Some OpenCart 4 releases group these fields under an **SMTP** heading and label them **Hostname**, **Username**, **Password**, **Port** and **Timeout**.

### Match the sender

On the **Store** tab of the same settings page, set **E-Mail** to an address on your verified domain, such as `orders@yourdomain.com`. OpenCart sends store emails from it.

---

## Test it

OpenCart has no test button for mail settings, so send a real store email to one of Groundmail's simulator addresses. They work over SMTP and never reach a real inbox. Register a customer account, or place a test order, with the email:

```text
delivered@simulator.groundmail.dev
```

Then confirm in Groundmail: open **Emails** in the dashboard, or run:

```bash
curl "https://api.groundmail.dev/emails?limit=5" \
  -H "Authorization: Bearer $GROUNDMAIL_API_KEY"
```

The email appears with the status `delivered` and `"test": true`. Use `bounce@simulator.groundmail.dev` to see a hard bounce. The full list is in [Testing](https://docs.groundmail.dev/testing#simulator-addresses). Send errors show in the admin under **System**, **Maintenance**, **Error Logs**.

---

## Troubleshooting

**Connection timed out or the TLS handshake fails.** Check the hostname is `tls://smtp.groundmail.dev` (with the prefix) and the port is `587`. If your host blocks outbound port 587, use `2525` with the same settings.

**Authentication failed.** The username must be exactly `groundmail`, and the password must be the SMTP credential (`gmsmtp_…`), not an API key (`gm_…`).

**The message is rejected because of the From address.** The store **E-Mail** must use a [verified domain](https://docs.groundmail.dev/domains) on your account. Until then you can only send from the sandbox sender, and only to your own account email.

**A recipient never receives the email.** The address may be on your suppression list, usually after a hard bounce. See [Suppressions](https://docs.groundmail.dev/suppressions), and create a [webhook](https://docs.groundmail.dev/webhooks) for `email.bounced` to get notified.

**Sends are deferred.** A new account has a daily ramp-up limit, and the Free plan has a daily limit. The relay replies with a temporary error and a retry time. See [Sending limits](https://docs.groundmail.dev/sending-limits).

---

## Related

- [SMTP relay](https://docs.groundmail.dev/smtp)
- [Testing](https://docs.groundmail.dev/testing)
- [Webhooks](https://docs.groundmail.dev/webhooks)
