Skip to content

Each VM has its own email address. A message to an enabled inbox wakes the VM and is saved on its disk; the inbox can also post each message to a webhook or take messages from a Telegram bot.

The inbox is off by default. The samples use a VM named support; VMs shows how to create it.

Enabling accepts mail at the VM’s address. Turning it on needs a plan with inbox_allowed, and mail to a disabled inbox is rejected at SMTP and wakes nothing.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Select Enable inbox. The badge changes to enabled.

The answer holds the state of the inbox: whether it accepts mail, its address, the sender rule, the webhook and the Telegram bot. webhook_secret appears only in the answer that sets or rotates the webhook.

Send mail to the address from any mail account, subject to the sender rule. The address uses the VM id, so renaming the VM does not change it. A +tag after the id is accepted and stored with the message.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Read the address in Address.
  4. Select Copy to copy it.

Delivery wakes a sleeping VM and writes the message into ~/inbox (/home/user/inbox). Each message is one row of ~/inbox/inbox.db, a SQLite database. The raw object is ~/inbox/raw/<id>.eml for mail and ~/inbox/raw/<id>.json for Telegram; attachments are in ~/inbox/files/<id>/, named <n>-<name>.

inbox ls lists messages newest first. An unread row has * in NEW; add --unread to keep only unread ones. inbox read <id> prints one message, and inbox mark-read <id> marks it read. inbox search <words> matches every word in the sender, sender name, subject, tag and text. An id may be any unique start, in any case.

inbox ls --json prints an array with id, channel, received_at, sender, sender_name, subject, tag, recipients, attachments and read_at. A program can parse that or open the SQLite database. Each attachment has name, type, size and path. Only a Telegram message can be answered: inbox reply <id> --text or --file sends to its chat, and there is no way to send new mail.

Messages stay on the disk until you delete the VM. From your laptop, si exec support -- inbox ls runs the same command in support.

allowed_senders is the sender rule for new mail. The default is null, so any sender can mail an enabled inbox. An empty list accepts none, and a list accepts exactly those SMTP envelope addresses. The rule matches the envelope sender, not the display name, and has no domain wildcards. --none refuses every sender, and --allow names one address and can repeat. A change applies to new mail only.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Choose Only these addresses under Who can write.
  4. Enter ada@example.com in Addresses.
  5. Select Save.

A webhook receives one signed POST per message. The URL must use https. A new or changed URL returns webhook_secret once; the old secret stops verifying signatures. Removing the webhook with si svm inbox webhook --remove stops the POSTs and deletes the secret.

Your endpoint must answer a 2xx status. Any other answer, or no answer, is retried up to 10 times: first after 10 seconds, then with the wait doubling to at most 5 minutes, about 30 minutes in all. After the last attempt the POST is dropped; the message stays in the VM’s inbox.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Enter https://example.com/hook in Webhook URL.
  4. Select Save.
  5. Select Copy under Webhook secret and store it.

Each POST carries an X-Slashinfra-Signature header of the form t=<unix seconds>,v1=<hex>. v1 is the hex HMAC-SHA256 of the timestamp, a dot and the raw request body, keyed with the webhook secret. Compute it over the raw request body before you parse the JSON, and compare the two values.

Reject a delivery whose timestamp is more than five minutes old, so a captured request cannot be sent again later. Compare in constant time.

import hashlib, hmac, time
def verify(secret: str, header: str, body: bytes) -> bool:
parts = dict(part.split("=", 1) for part in header.split(","))
timestamp, signature = parts["t"], parts["v1"]
if abs(time.time() - int(timestamp)) > 300:
return False
expected = hmac.new(secret.encode(), f"{timestamp}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)

Pass the body exactly as it arrived: in a web framework, read the raw bytes, not the parsed JSON.

The body is JSON. event is message.received, machine is the VM id, message is the envelope and raw_url serves the raw message for one hour. The envelope holds its channel, sender, recipients, subject, text, HTML, attachments and the SPF, DKIM and DMARC results, among other fields.

Rotate makes a new secret for the current webhook and returns it once. The old secret stops verifying X-Slashinfra-Signature on every later POST. A webhook must be set first, or the call answers 409 no_webhook.

Terminal window
curl -sS -X POST "https://api.slashinfra.com/svms/support/inbox/webhook/rotate" \
-H "Authorization: Bearer $SI_API_KEY"
Output
{"enabled":true,"address":"6f1c0f0e8a@slashinfra.dev","allowed_senders":["ada@example.com"],"webhook_url":"https://example.com/hook","telegram":{"connected":false,"bot_username":null,"allowed_users":[],"pair_code":null,"pair_expires_ms":null},"webhook_secret":"whsec_..."}

A Telegram bot sends its chats to the same inbox. Connecting checks the token with Telegram, stores it in the vault and registers the bot’s webhook; no answer returns the token. The inbox must be on and the plan must allow inboxes. The answer holds bot_username and a pair_code.

Run si svm inbox telegram support connect; it reads the token from standard input or --token-file, never from an argument. The control call is PUT /svms/{ref}/inbox/telegram with bot_token.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Enter the token from BotFather in Bot token.
  4. Select Save. The bot username and a pairing code appear.

A pairing code is single-use and valid for ten minutes. The user sends /start <code> to the bot; that Telegram user joins allowed_users, and the bot answers paired.

Run si svm inbox telegram support pair or POST /svms/{ref}/inbox/telegram/pair for a new code; it replaces the live one. Without a bot the call answers 409 not_connected.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Select New pair code.
  4. Send /start and the code to the bot from the Telegram account.

allowed_users holds the numeric Telegram user ids whose messages reach the inbox. It replaces the stored list whole and drops duplicates. An empty list accepts none, and a paired user is added automatically.

si svm inbox telegram support users <id>... takes the ids as arguments; PUT /svms/{ref}/inbox/telegram/users takes allowed_users. Without a bot the call answers 409 not_connected.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Enter the ids in Allowed user ids, one per line.
  4. Select Save.

Disconnect removes the bot, its webhook, its token and its injection rule, and stops Telegram messages. It keeps the other inbox settings and the messages already on the disk.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Select Disconnect. The bot stays for 5 seconds, and Undo keeps it.

Disabling rejects new mail at SMTP and wakes nothing. It keeps the sender rule, the webhook and every message already on the disk, so enabling again restores them.

  1. Open SVMs and select support.
  2. Select the Inbox tab.
  3. Select Disable inbox. The badge changes to disabled.

enabled is required on the inbox call, and bot_token and allowed_users are required on their calls. The other fields keep their value when you omit them.

Field Type Default Allowed values What it changes
enabled boolean Required true or false Whether the inbox accepts mail. The CLI turns it on with si svm inbox enable and off with si svm inbox disable.
allowed_senders (--allow, --none) array of strings or null null null for any sender, [] for none, or exact addresses such as ada@example.com; each at most 254 characters The rule for new mail. Omit it to keep the current rule. Stored entries are trimmed, lowercased and deduplicated, and match the SMTP envelope sender.
webhook_url ([URL], --remove) string or null null An https:// URL; null removes it Each message is POSTed to it. Omit it to keep the current webhook; a new or changed URL returns a new webhook_secret once.
bot_token (--token-file) string Required for connect The token from BotFather Checks the bot with Telegram, stores the token in the vault and registers its webhook. The token is never returned.
allowed_users ([ID]...) array of strings Required for users Numeric Telegram user ids; [] accepts none Replaces the stored list whole and drops duplicates. It is empty until the first pair, and a paired user is added automatically.
project (--project) string default A project name, or its proj_ id The project that holds the VM.
ref (<SVM>) string Required A VM name, or its 10-symbol id The VM whose inbox the operation acts on.

Scroll horizontally to see all columns.

State What it means for you What you can do
enabled Mail from an allowed sender is accepted, wakes the VM and is saved. A webhook, if set, receives each message. Change the rule or webhook, connect Telegram, disable the inbox.
disabled Mail is rejected at SMTP and wakes nothing. Messages already saved stay on the disk, and the rule and webhook stay. Enable the inbox. The API and CLI can change the rule and webhook while it is off.

Scroll horizontally to see all columns.

Code When Fix
invalid_webhook Set a webhook sends a URL that is not https. Use an https:// URL that is publicly reachable.
invalid_sender Set the sender rule sends a value that is not one exact address. Use full email addresses, one exact address per entry.
inbox_not_allowed Enable the inbox or connect Telegram on a plan without inboxes. Ask your administrator about the plan.
inbox_disabled Connect Telegram while the inbox is off. Enable the inbox first.
invalid_bot_token Connect sends a token that Telegram refuses. Use the token from BotFather.
not_connected Pair a user or set the users with no bot connected. Connect a bot first.
invalid_user Set the Telegram users sends a value that is not numeric. Use numeric Telegram user ids.
no_webhook Rotate runs before a webhook is set. Set a webhook first.
telegram_unavailable Telegram does not answer the connect call. Try again.

Scroll horizontally to see all columns.

Errors that any request can return are in the error catalog.

Operation Who can Key action
Show the inbox Any member svm:read
Enable or disable the inbox Any member svm:write
Change the sender rule Any member svm:write
Set or remove the webhook Any member svm:write
Rotate the webhook secret Any member svm:write
Connect a Telegram bot Any member svm:write
Pair a Telegram user Any member svm:write
Set the Telegram users Any member svm:write
Disconnect the bot Any member svm:write

Scroll horizontally to see all columns.

  • Both plans include inboxes (inbox_allowed). A plan without it answers 403 inbox_not_allowed when you enable.
  • An email has a maximum of 25 MiB, attachments included. A larger message is rejected at SMTP.
  • For mail, the inbox stores three authentication results, SPF, DKIM and DMARC, but does not filter on them. The sender rule is the only mail sender filter.
  • One webhook per inbox. Its raw_url serves the raw message for one hour.
  • One Telegram bot per inbox. A pairing code is single-use and expires after ten minutes.
  • One sender rule entry is one exact SMTP envelope address, lowercased and deduplicated; there are no domain wildcards.
  • Each VM has one address, <id>@slashinfra.dev, and it does not change when you rename the VM. Messages stay on the disk until you delete the VM.

The full list is in Limits.