Hearth documentation

Mailboxes and mail

Mail touches Hearth in three ways, each set up on its own:

Mail itself stays on the mail servers. Hearth keeps only how to reach each mailbox, with passwords and tokens sealed by the master key.

Outgoing mail

Hearth sends its own mail through an SMTP server you name. Set all of these, or none:

Setting Example Notes
MAIL_SMTP_HOST smtp.example.org
MAIL_SMTP_PORT 587 465 for tls, 587 for starttls
MAIL_SMTP_TLS starttls tls, starttls, or none (only for a relay on localhost)
MAIL_SMTP_USERNAME noreply@example.org leave empty for a relay without login
MAIL_SMTP_PASSWORD_FILE /run/hearth/smtp-password a file holding the password; needs the username
MAIL_FROM noreply@example.org a plain address
MAIL_FROM_NAME Hearth the sender's name (default Hearth)

Without outgoing mail, inviting people, guests and emailed codes are not available.

Hearth never sends to placeholder addresses (those in the reserved example domains, such as example.com, and in .invalid, .local and similar), nor to accounts that have only a placeholder address.

If your rules require it (HIPAA, for example), every company your mail passes through must sign an agreement with you. Sending through your own Hearth Mail, with no outside relay, avoids one such company; it needs a clean server address with matching reverse DNS, outbound port 25 open at your host, and SPF, DKIM and DMARC for your domain.

A mailbox for every new member

With Hearth Mail, the suite's mail server, Hearth can make a mailbox for each new member and connect it as their own mailbox in Mail.

Connecting Hearth Mail

On the mail server, make an API key for an account that may manage accounts (find, create, change and delete them, and read domains) but not change the server's settings. Then set:

Restart Hearth. Administration, Mailboxes then reads "Hearth Mail connected"; without the settings it reads "Hearth Mail not connected" and cannot be switched on.

Switching it on

  1. Go to Administration, Mailboxes.
  2. Type the Domain the mail server hosts, such as example.org.
  3. Under Address, choose the pattern for new addresses: first.last, firstlast, flast, first or username.
  4. Optionally set a Quota (GB) for each mailbox. Leave it empty to use the mail server's own.
  5. Set Keep a deleted member's mail (days).
  6. Turn on A mailbox for every new member and select Save. Hearth checks that the mail server hosts the domain.

From then on, when an invitation is accepted, or someone signs in through your organisation's provider for the first time, Hearth makes a mailbox at the first free address of the pattern, with a random password and the quota, and connects it as the person's own mailbox in Mail. Names without the letters a to z (in Arabic script, for example) use the username instead.

The line under the switch counts the active mailboxes and those kept after their owner's account was deleted.

When a member leaves

When you delete an account, its mailbox is locked at once (a new password nobody knows, its other sign-ins removed) and deleted with its mail after the number of days you set. If the person is under a legal hold, the mail server is told to hold their mailbox too.

Connecting a mailbox by hand

For people who joined before Mailboxes was switched on, or whose mailbox is on Hearth Mail already, connect it from the server. The password is read from standard input:

docker compose exec -T hearth /hearth mail native set --username jsmith \
  --address https://mail.example.org --login jsmith@example.org < password.txt

hearth mail native remove --username jsmith disconnects it. The mail stays on the server.

A person's own mailbox is listed first in Mail and is the default sender. Only an admin can remove it.

The mail policy

People can add other mailboxes beside their own: Gmail, Microsoft 365, and any IMAP or JMAP server. The Other mailboxes rule in a security policy can allow any, only those on domains you list, or none but their own. A mailbox the policy does not allow is refused when added, and one added before is switched off without deleting anything on its server.

Gmail and Microsoft sign-in pages

People can always connect Gmail or Microsoft mailboxes with an app password. To let them use Google's or Microsoft's own sign-in page instead, register an OAuth client with each and give Hearth its details.

The redirect address for both is https://hearth.example.org/api/v1/mail/oauth/callback.

Google

  1. In the Google Cloud console, create an OAuth client of type Web application, with the redirect address above.
  2. On the consent screen, add the scope https://mail.google.com/, plus openid and email.
  3. Set MAIL_GOOGLE_CLIENT_ID to the client ID and MAIL_GOOGLE_CLIENT_SECRET_FILE to a file holding its secret.

Microsoft

  1. In the Microsoft Entra admin centre, register an application with a Web redirect URI set to the address above.
  2. Under API permissions, add the delegated permissions IMAP.AccessAsUser.All, SMTP.Send, offline_access, openid and email.
  3. Make a client secret, then set MAIL_MICROSOFT_CLIENT_ID and MAIL_MICROSOFT_CLIENT_SECRET_FILE.

Other mail servers

Some mail servers accept OAuth sign-in only from clients they know. Name the clients registered for Hearth on them in MAIL_OAUTH_CLIENTS, as issuer=client-id pairs separated by commas:

MAIL_OAUTH_CLIENTS=https://mail.example.org=hearth-example-org

Other mail settings

All mail settings are in the configuration reference.