E-mail log

Every e-mail Tienda sends is written to a log for the shop it belongs to. The log answers: what was sent, when, to whom, by which staff member or job, about which record, and what happened to it.

What is recorded

FieldNotes
TimeWhen the mail was handed to delivery.
RecipientsTo, cc and bcc.
SubjectSecrets in it are hidden.
KindWhich mail it is (an order confirmation, a pay link, a sign-in code).
Sent byThe staff member whose action caused it, or the name of the job, or "system".
AboutThe record it concerns, such as an order, with a label like "Order #1042".
StatusSee below.
ErrorThe error text when sending failed, including mail the mail server refused.
TextThe text of the mail.

One row is made for each delivery attempt. A mail that fails and is sent again gives a failed row and then a sent row. A mail that is not handed to the mail server on purpose, because delivery is disabled on the installation or the shop's e-mail is switched off, is logged as skipped. A mail that is never handed to delivery at all is not logged. Attachments are not kept; only their name, type and size are. Bodies are cut at a fixed length.

Statuses: queued, sent (accepted by the mail server), failed, skipped (not handed to the mail server on purpose, see below), and the delivery results delivered, delayed, held and bounced described below.

Secrets are hidden

Sign-in codes and links are masked in the stored text. The mail that is sent is not changed.

Who may read it

  • Shop administrators. They open it in the back office under Settings, Integrations, Email Log. The page title is "E-mail log". It has filters on status, recipient, kind and dates, a detail view with the delivery history, and a safe preview of the HTML.
  • Another role can be given the permissions settings.email_logs#index and settings.email_logs#show. The default roles do not have them. The back-office page itself is opened by administrators.
  • Nobody can change or delete a row by hand.

Delivery results

Without more, the log shows what Tienda handed to the mail server. A result such as delivered, delayed or bounced arrives only when the mail server reports it, through a signed webhook that an operator has connected.

The log shows delivery only after the webhook is connected

Until an operator connects the mail server's webhook, the log shows what was sent, not whether it arrived. Whether this is connected depends on the installation.

For operators: the mail server posts to https://<your Tienda API host>/webhooks/email_status/<provider>. The providers are postal and karta.

  • The call must be signed. A call with a missing or wrong signature is refused with 401 and changes nothing. With no key configured, every call is refused.
  • The mail is found by its Message-ID header, which Tienda sets before sending.
  • A body that is not JSON answers 400. Everything else answers 200, also for a mail the log does not know, so the mail server does not retry it.
  • A repeated report with the same event id is ignored. When a mail has several recipients, the row takes the most serious of the latest result per recipient.

Events to switch on at the mail server: sent, delayed, failed, held and bounced. For Postal these are MessageSent, MessageDelayed, MessageDeliveryFailed, MessageHeld and MessageBounced, with request signing on. For Karta they are message.accepted, message.delivered, message.deferred, message.bounced and message.suppressed. The settings that hold the keys are POSTAL_WEBHOOK_PUBLIC_KEY and KARTA_WEBHOOK_SECRET (Configuration).

Switching a shop's e-mail off

A shop can have all its outgoing mail stopped. The shop setting outgoing_email is a safeguard with two states. Set to on, or not set at all, mail goes out. Set to anything else, off included, the shop's mail is stopped: a mistyped value never switches the safeguard back on.

What is stopped: order and ticket mails, pay links, newsletters, reminders, notices to the shop itself, staff invitations, and the sign-in codes of the shop's customers (no code is sent to a customer address while every shop it belongs to has its mail off).

  • Each stopped mail is still in the log, with the status skipped and the text "Not sent: outgoing e-mail is switched off for this shop."
  • Sign-in codes for staff are never stopped, so that someone can always sign in to switch mail on again.
  • The operator variable OUTGOING_EMAIL=off does the same for every shop of the installation, and the text says "for this installation".
  • A mail whose shop cannot be told is not sent either, and is logged as skipped with "shop unknown", so a job that lost its shop is found and not hidden.
  • The check is one rule for every kind of mail, so no mail can forget it. If the switch cannot be read, the mail is not sent.
  • The E-mail log page shows a notice while mail is switched off.

There is no toggle in the back office. The setting is changed through the shop settings API (PATCH /api/v1/applications/current with outgoing_email) by an operator of the installation only. A shop's own administrator can read the setting but cannot change it: the request is accepted and the field is ignored.

Retention

A job runs every day at 03:00 for all shops:

  • Text and HTML of mails older than 90 days are removed. The row stays, with recipients, subject, status and history.
  • Rows older than 400 days are deleted.

Both limits are set by the operator with EMAIL_LOG_BODY_DAYS and EMAIL_LOG_ROW_DAYS. The body limit is never longer than the row limit. There is no setting per shop. See Data retention.