# Mail Log: overview

<!-- prettier-ignore-start -->

Someone tells you the password reset never arrived, and you need to know if your site sent it. This keeps a record of every email the site sends, so you can look it up in the admin and see what happened to it.

Each email gets a line with its subject, the part of the site that sent it, the time and how far it got. If your developer connects Postmark delivery reports, you also see if each email was delivered, bounced or marked as spam. A bounce shows its reason. When an email fails before it leaves your server, the reason is kept too.

The text of a sent email is never stored. Addresses are kept only as a code, so the list never shows who an email went to. Messages the circuit breaker holds back are kept encrypted until an administrator decides. You can still find every email sent to one person by typing their full address into the filter, and a privacy request for that person exports or deletes their entries.

Only global administrators with the right permission can open the list, which is read-only. Entries are kept for 90 days by default. Change that in the settings. Old entries are removed by a daily clean-up, which needs the scheduler running on your server.

## What it does for you

Mail Log keeps one row for every email the site sends through Laravel's mailer, whether a notification or a mail class sent it. Each row shows the subject, the class that sent it, the mailer it went through and its status. Sending means the mailer took it, sent means the mail service accepted it and failed means the send raised an error. Suppressed means Postmark refused an address it has marked inactive. With Postmark's delivery reports connected, rows also move to delivered, bounced or marked as spam.

## Setup requirements

Run the Capell migrations so the two mail log tables exist, and keep the Laravel scheduler running for the daily clean-up. To record deliveries, bounces and spam reports from Postmark, set `MAIL_LOG_POSTMARK_WEBHOOK_USERNAME` and `MAIL_LOG_POSTMARK_WEBHOOK_PASSWORD`, then add a Postmark webhook for Delivery, Bounce and Spam Complaint that points at `/capell/webhooks/mail-log/postmark` with the same Basic-auth credentials. Run the package check in **Diagnostics** to confirm the tables, the mail listeners, the Postmark credentials and the clean-up.

## Your screens

- **Developer > Mail log**: the read-only list of sent email, with filters for status, mailer, sending class, recipient address and date.
- **Mail log entry**: one email's subject, sending class, provider message ID, timeline and, when it did not arrive, the reason.
- **Extensions > Mail log settings**: switch recording on or off and choose how many days rows are kept.

## What you can do

- Check whether a particular email was sent, accepted by the mail service and delivered.
- Find every email sent to one person by typing their full address into the recipient filter.
- See why an email bounced or failed, with addresses and credentials removed from the reason.
- Change how long rows are kept.

## Where to find it

Open **Developer > Mail log** in the admin. Only global administrators with the **View the mail log** permission can see it.

## Good to know

- The body and attachments of a sent email are never stored. A message the circuit breaker holds back is kept encrypted until it is released or discarded, then its content is deleted. Recipient addresses are stored only as a keyed code, so the list cannot show them and the recipient filter needs the whole address.
- A privacy request for a person exports the emails sent to them and erases their entries. An email that also went to other people stays for those people with this person removed.
- An email still shown as sending an hour after it was handed to the mailer is marked failed by the daily clean-up, because the mailer never confirmed it.
- Rows older than the retention setting (90 days by default) are deleted by `capell:mail-log-prune`, which runs daily on one server.

---

For how to use Mail Log, see the [admin guide](admin-guide.md).
For developers: see the [README](../README.md).

<!-- prettier-ignore-end -->