Email

Send receipts, ready-to-collect notices, purchase orders, set-password links and alerts through your own mail server or provider.

See it in the tour: Set up email

On this page

Stater sends email through your own mail server or provider (SMTP). Email is part of every plan, Starter included. Nothing in Stater needs it: without email, receipts print, purchase orders are sent another way and staff get temporary passwords read out to them.

Three ways to set it up#

  1. At deployment. Set STATER_SMTP_HOST, STATER_SMTP_FROM and the rest of the variables below (the installers ask for them: Linux packages, Docker Compose). The server's environment then owns the connection: Admin › Email shows the server, port, security, user name, password and From address read-only, with the variable that sets each. A deployment that leaves email to later sets STATER_SMTP_SETUP=admin (an owner sets it up; Today reminds them) or later.
  2. In the setup wizard. After the company, store and owner are made, the wizard asks about email: Set it up now (it saves the settings and sends you a test email), An admin will set it up later (owners see "Set up email" on Today until it is done) or Skip for now. If the server's environment already sets email, the wizard only offers a test.
  3. Any time later, in Admin › Email (owners, and anyone with Settings access across every store). The page has Send test email, and a Sent and queued tab with every email, its status and the last error, where a failed email can be tried again and a queued one stopped.

The password is never shown again once saved. It is kept encrypted with the server's secret key (Secrets), so a server without STATER_SECRET_KEY cannot save one: the wizard then offers a relay that needs no password, or leaving email to an admin, with the command to make a key.

Which settings win#

Field STATER_SMTP_HOST set Not set
Server, port, security, user name, password, On my own network environment, locked Admin › Email
From address STATER_SMTP_FROM, locked Admin › Email
From name STATER_SMTP_FROM_NAME when set (locked), else Admin › Email, else the company name Admin › Email, else the company name
Replies go to, Alerts go to, Tell customers when their order is ready Admin › Email Admin › Email

With the host in the environment, the saved settings are ignored, never mixed: an environment host is never paired with a saved password. Remove STATER_SMTP_HOST and the saved settings apply again.

Settings#

Variable Default
STATER_SMTP_HOST empty The mail server, such as smtp.office365.com. Setting it sets email up from the environment.
STATER_SMTP_PORT 587, 465 for tls, 25 for none
STATER_SMTP_SECURITY starttls starttls, tls (encrypted from the first byte) or none. Stater never falls back from STARTTLS to plain text, and never skips certificate checks.
STATER_SMTP_USERNAME empty Empty: no sign-in. Stater uses AUTH PLAIN, or LOGIN when the server offers only that.
STATER_SMTP_PASSWORD, STATER_SMTP_PASSWORD_FILE empty The file is preferred. An empty file means no password. A password needs a user name, and none security is refused with a password unless the server is this machine.
STATER_SMTP_FROM Required with a host. One address.
STATER_SMTP_FROM_NAME the company name
STATER_SMTP_ALLOW_PRIVATE false The mail server is on a private or loopback address. Counts only while STATER_PRIVATE_CONNECTORS is true.
STATER_SMTP_SETUP empty Without a host: admin or later.

A setting Stater cannot read stops the server at start with a sentence naming it.

With compose, put STATER_SMTP_PASSWORD in .env (or mount the password file into the stater container yourself): compose mounts no file for STATER_SMTP_PASSWORD_FILE, which is for packaged installs and Kubernetes secrets.

STATER_SMTP_FROM_NAME and the other variables count only with STATER_SMTP_HOST. Admin › Email says which variable sets each locked field; a field whose own variable is not set has its default because the host is set.

Examples#

  • Microsoft 365: smtp.office365.com, port 587, STARTTLS, the mailbox's address as user name. The mailbox needs SMTP AUTH turned on.
  • Google Workspace: smtp.gmail.com, port 587, STARTTLS, with an app password; or Google's SMTP relay (smtp-relay.gmail.com) allowed for your server's address and no password.
  • A relay in the back office: its address, security none and no user name, with "On my own network" ticked (or STATER_SMTP_ALLOW_PRIVATE=true).

What Stater emails, and to whom#

Mail only goes to an address someone typed, or the one already on the record it is about.

Email To Sent when
Receipt the customer's email, or an address typed at the counter or on the order someone presses Email receipt (sell access, in that store). At most 5 a day per order.
Ready to collect the customer's email an order moves to Ready to collect, once each time, while "Tell customers when their order is ready" is on; or Email ready notice on the order.
Purchase order the supplier's email, or one typed Email to supplier on a purchase order. A draft is marked sent as it goes; an open order can be emailed again.
Set-password link the staff member's email Email a set-password link on their record (People › Staff). A new person gets an invite that works for 3 days; someone who already chose a password is reset: signed out everywhere, PIN cleared, API tokens revoked, and the link works for 24 hours.
Alert Alerts go to, or every owner with an email address the server raises an alert (a failed backup, a licence running out). At most one an hour per alert and person.
Test whoever it is sent to Send test email.

Each person can queue at most 60 emails an hour. Accounts that sign in through a company directory get no set-password links.

How sending works#

An email is a row in the mail outbox, written in the same transaction as what it is about, so a change that does not save sends nothing. Every replica runs a worker that claims due emails (FOR UPDATE SKIP LOCKED), sends up to four at once and records the outcome. A temporary failure (the network, a 4xx reply, a timeout) is tried again after 1, 5 and 15 minutes, 1 hour and 3 hours; a permanent one (an address or password refused) fails at once, and the order, purchase order or staff record shows "Email not sent". Failed emails show on Today for owners, and stater_mail_failed in /metrics (Monitoring) counts the last day's.

Set-password links are single-use and only the SHA-256 of their token is stored. The token is made when the email is actually sent, so the outbox never holds a working link, and it travels after the # in the address, so it never reaches a server log or a Referer header. A newer link, any other password change and deactivating the person all end it.

Retention#

The text of sent emails is blanked after 7 days (receipts hold personal details), and finished emails are deleted after 30 days. Expired password links go a week after they ran out. The hourly job "Email clean-up" does this.

When it does not work#

Message What to do
The mail server refused the username or password. Check them. Microsoft 365 and Google need SMTP sign-in allowed for the mailbox, or an app password.
The mail server does not offer STARTTLS on this port. Choose TLS (usually port 465), or the port your provider gives for STARTTLS (usually 587).
The mail server did not answer in time. Check the server and port, and that a firewall lets Stater out on that port. Many hosting providers block port 25.
The host name of the mail server could not be found. Check the server name for typos.
The mail server's certificate was not accepted. The server's certificate must be valid for the name you typed. Use the provider's own host name, not an address.
… is on a private or internal network … Tick "On my own network" if the server really is in your network.
Private network addresses are turned off on this server. STATER_PRIVATE_CONNECTORS=false on this server; use a public mail server.
The mail server would not send from that address. The From address must be one the account may send as.
The mail server would not deliver to that address (550 …). The address is wrong or the mailbox is gone; fix it on the customer, supplier or staff record.
Email is not set up yet. An owner sets it up in Admin › Email.

API#

Endpoints: GET /email/info (public), GET/PUT /settings/email, POST /settings/email/test, GET /email/outbox, POST /email/outbox/{id}/retry and /cancel, POST /orders/{ref}/email-receipt, POST /orders/{ref}/notify-ready, POST /purchase-orders/{ref}/email, POST /staff/{id}/email-link, and the public POST /password-links/check and /password-links/use. Changing the password, testing and turning on "On my own network" need the web app; API tokens get 403.

email.* live-update topics reach only those with Settings access, and carry ids, never addresses. They are not in the webhook topic list.