Skip to content

pimalaya/sirup

Sirup Matrix Mastodon

CLI to spawn pre-authenticated IMAP/SMTP sessions and expose them via Unix sockets

Table of contents

Features

  • IMAP support (requires imap cargo feature)
  • SMTP support (requires smtp cargo feature)
  • TLS support:
    • native-tls (requires native-tls feature)
    • rustls:
      • AWS-LC crypto provider (requires rustls-aws feature)
      • Ring crypto provider (requires rustls-ring feature)
  • SASL support:
  • Pre-authenticated IMAP/SMTP session proxied to a Unix socket via sirup start <account>
  • REPL that interacts with the Unix-socket-backed session via sirup repl <account>
  • Partial JSON support with --json

Sirup CLI is written in Rust, and relies on cargo features to enable or disable functionalities. Default features can be found in the features section of the Cargo.toml, or on docs.rs.

Installation

Pre-built binary

Sirup CLI can be installed with the installer:

As root:

curl -sSL https://raw.githubusercontent.com/pimalaya/sirup/master/install.sh | sudo sh

As a regular user:

curl -sSL https://raw.githubusercontent.com/pimalaya/sirup/master/install.sh | PREFIX=~/.local sh

These commands install the latest binary from the GitHub releases section.

If you want a more up-to-date version than the latest release, check out the releases GitHub workflow and look for the Artifacts section. You should find a pre-built binary matching your OS. These pre-built binaries are built from the master branch, using default features.

Cargo

Sirup CLI can be installed with cargo:

cargo install sirup

You can also use the git repository for a more up-to-date (but less stable) version:

cargo install --locked --git https://github.com/pimalaya/sirup.git

Nix

Sirup CLI can be installed with Nix:

nix-env -i sirup

You can also use the git repository for a more up-to-date (but less stable) version:

nix-env -if https://github.com/pimalaya/sirup/archive/master.tar.gz

Or, from within the source tree checkout:

nix-env -if .

If you have the Flakes feature enabled:

nix profile install sirup

Or, from within the source tree checkout:

nix profile install

You can also run Sirup directly without installing it:

nix run sirup

Configuration

The wizard is not yet available (it should come soon), meanwhile you can manually edit your own configuration from scratch:

  • Copy the content of the documented config.sample.toml
  • Paste it into a new file ~/.config/sirup/config.toml
  • Edit, then comment or uncomment the options you want

Usage

Start a pre-authenticated session

$ sirup start <account>

This command spawns a blocking daemon that connects to your IMAP or SMTP server (depending on the account's URL scheme), performs the TLS negociations if necessary, authenticates you, then exposes this session via a Unix socket.

Any client that can connect to, read responses from and write commands into Unix sockets can interact with the session.

The protocol-level greeting is replaced by:

  • IMAP: * PREAUTH [CAPABILITY…] Sirup IMAP pre-auth session ready
  • SMTP: 220 Sirup SMTP pre-auth session ready

The IMAP EHLO-equivalent capability list reflects whatever the upstream server advertised after authentication.

Launch a REPL

$ sirup repl <account>

S: * PREAUTH [CAPABILITY…] Sirup IMAP pre-auth session ready

C: <Enter your IMAP raw command>

The REPL is a simple client that connects to the Unix socket and forwards raw commands. It picks IMAP or SMTP framing based on the account's URL scheme. Mostly useful for testing and as a demonstration on how to implement clients.

FAQ

How to debug Sirup CLI?

The simplest way is to pass --log-level=<level> (alias --log=<level>), where <level> is one of off, error, warn, info, debug, trace.

The advanced way is based on environment variables:

  • RUST_LOG=<filter>: determines the log level filter (per-target syntax supported, see the env_logger documentation). Consulted only when --log-level is not passed.
  • RUST_BACKTRACE=1: enables the full error backtrace, which includes source lines where the error originated from.

Logs are written to stderr, which means that you can redirect them easily to a file:

sirup start example --log-level=debug 2>/tmp/sirup.log

You can also send logs straight to a file via --log-file=<path>:

sirup start example --log-level=debug --log-file=/tmp/sirup.log

Social

Sponsoring

nlnet

Special thanks to the NLnet foundation and the European Commission that have been financially supporting the project for years:

If you appreciate the project, feel free to donate using one of the following providers:

GitHub Ko-fi Buy Me a Coffee Liberapay thanks.dev PayPal