Mail and the outgoing-mail relay
How mail reaches the box on port 25, why outgoing mail leaves through the cloud provider's email service on port 587, and the thx relay commands that check each step.
Mail on the box is Stalwart, one server for every company domain. People's addresses and passwords come from the directory; Stalwart stores only the mail.
Incoming mail: straight to the box
Other mail servers deliver to the box on port 25, at the mail. name your domain's MX record points to. Nothing sits in between. People read mail on port 993 (IMAP over TLS), in the webmail app, or in any mail client, and send on 465 or 587.
Outgoing mail: through the relay
The cloud provider blocks outgoing connections on port 25, so the box cannot deliver to other servers directly. Every message for an outside address leaves through the cloud provider's email service, the outgoing-mail relay, in your box's region, on port 587 with STARTTLS required and the certificate verified. The email service signs the mail with DKIM.
thx holds no cloud API key, so everything on the provider's side is done by hand in your cloud console:
- Create an Email Domain for each company domain.
- Create its DKIM key and note the selector and the CNAME value the console shows.
- Create SMTP credentials for a user allowed to send.
- Add an Approved Sender for every address that sends: at least
noreply@<apps domain>, which the box uses for invitations and notices, and each person's address.
Connect the box to the relay
Give the mail piece the SMTP credentials. Each value is read from standard input, so it never appears in your shell history or in the process list:
sudo thx secret set stalwart relay_host
sudo thx secret set stalwart relay_user
sudo thx secret set stalwart relay_password
sudo thx apply
The relay host is smtp.email.<region>.oci.oraclecloud.com. When the relay_host input is empty, the relay commands (thx relay check, thx relay test) use the box's own region.
Record the DKIM record the console showed you, so thx dns can print it: sudo thx relay dkim acme.example <selector> <target>. Add --verified once your cloud console says the key is active.
Check each step
sudo thx relay status acme.exampleshows where the relay stands: region and SMTP host, email domain, DKIM, credentials and approved senders. Steps on the provider's side read "by hand", because the box cannot see them.sudo thx relay checksigns in to the relay's SMTP server with the stored credentials. Exit code 1 means the relay refused them; 3 means it could not ask (no network, a temporary error, or no credentials yet).sudo thx relay test --to you@example.comsends one test message through the relay asnoreply@and uses the same exit codes. It proves the credentials and the approved sender.sudo thx mail send --to you@example.com --subject "Hello"sends a plain-text message fromnoreply@<apps domain>, with the body on standard input.
When the relay refuses a sender
If the From address is not an Approved Sender, the relay answers 535 and the message bounces back to the person who sent it, with a notice naming the refusal. Add the address as an Approved Sender in your cloud console and send again. noreply@<apps domain> has no mailbox, so its bounces have nowhere to go; send a thx relay test after any change on the provider's side.
Mail clients
Phones and desktop clients find their settings through the autoconfig. and autodiscover. names, and through the optional SRV records thx dns prints. People sign in with their address and their office password: there are no separate app passwords. On an iPhone or a Mac, the Home app's connect page offers a profile that sets up mail, calendar and contacts at once, without the password.