End-to-end encrypted email for the mesh networking age rewritten in Rust.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
bubblegum 4aad790126 fix: clear the clippy warnings
cargo clippy --workspace --all-targets now reports nothing (it found 25). Most are mechanical:
let-chains for collapsible ifs, is_multiple_of, div_ceil, flatten, needless Ok(?), a function
moved above its test module. By hand:

- IMAP SELECT ran a mail_list query whose result was never used; it is gone.
- The sender's poll interval comes out of the select; its initial value was never read.
- An unused constant, a dead local in the mobile crate and redundant test imports are removed.
- ymp uses its existing ReassemblyMap alias; the constants test asserts at compile time.
- Mobile NodeState keeps the YMP and QUIC sessions only to hold them alive: _ymp and _quic.
- yggmail-mobile allows clippy::large_const_arrays: the flagged const is uniffi's generated
  scaffolding, and a lint attribute on the include_scaffolding! call is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 08:50:20 +03:00
.cargo Initial release 2026-07-12 10:04:19 +03:00
crates fix: clear the clippy warnings 2026-11-20 08:50:20 +03:00
.gitignore chore: ignore the local .claude directory 2026-11-17 19:42:12 +03:00
Cargo.lock build(deps): take the rustls fork from GitHub 2026-11-20 08:04:50 +03:00
Cargo.toml build(deps): take the rustls fork from GitHub 2026-11-20 08:04:50 +03:00
LICENSE Initial commit 2026-07-10 11:48:27 +00:00
README.md build: replace the Android scripts with the commands in the README 2026-11-10 22:05:46 +03:00
rust-toolchain.toml Initial release 2026-07-12 10:04:19 +03:00

yggmail-ng

Peer-to-peer email over the Yggdrasil mesh network, written in Rust. It is the mail engine of Tyr and is wire-compatible with yggmail 1.8 (Go).

There are no mail servers in between: nodes deliver to each other directly, and an address is the node's Ed25519 public key, <hex pubkey>@yggmail. Mail clients (Thunderbird, Delta Chat, ArcaneChat) talk to it over SMTP and IMAP on localhost.

Build

Needs stable Rust and a C compiler (rusqlite builds the bundled SQLite). Yggdrasil-ng, imap-rs and the rustls fork are git dependencies pinned to exact commits; cargo fetches them.

git clone https://git.shd.company/bubblegum/Yggmail-ng
cd Yggmail-ng
cargo build --release

Run

./target/release/yggmail --genconf   # writes yggdrasil.toml and yggmail.toml
# add peers to yggdrasil.toml, then:
./target/release/yggmail

Point the mail client at SMTP 127.0.0.1:1025 and IMAP 127.0.0.1:1143. The desktop binary has no authentication or TLS; both servers accept loopback connections only.

yggmail [--config FILE] [--yggmail-config FILE] [--genconf] [--help] [--version]

yggmail.toml:

db_path = "yggmail.db"
smtp_port = 1025
imap_port = 1143

yggdrasil.toml is a regular Yggdrasil-ng config (private_key, peers, listen).

How mail travels

mail client <-SMTP/IMAP-> yggmail <-QUIC-> Yggdrasil mesh <-> peers
                            |
                      SQLite (yggmail.db)

Outgoing mail is an SMTP dialog over a QUIC stream (quinn on top of the mesh), the same protocol yggmail 1.8 speaks. Each side pins the other's Ed25519 key from its TLS certificate, and a sender may only send as its own address. Inbound also accepts YMP, the protocol of 1.9.0 nodes; it is due to be removed.

Stored mail and the private key are encrypted at rest when a password is set (the Android library always sets one).

Android library

crates/yggmail-mobile exposes the engine to Kotlin through UniFFI. Building it needs the Android NDK (ANDROID_NDK_HOME), cargo-ndk and the Android Rust targets:

rustup target add aarch64-linux-android armv7-linux-androideabi x86_64-linux-android i686-linux-android
cargo install cargo-ndk

# libyggmail_mobile.so, one target per ABI you ship
cargo ndk --target aarch64-linux-android   --platform 21 -- build --release -p yggmail-mobile
cargo ndk --target armv7-linux-androideabi --platform 21 -- build --release -p yggmail-mobile
cargo ndk --target x86_64-linux-android    --platform 21 -- build --release -p yggmail-mobile
cargo ndk --target i686-linux-android      --platform 21 -- build --release -p yggmail-mobile

# Kotlin bindings, generated from the UDL: the release .so is stripped of the UniFFI metadata,
# and bindgen run on it writes nothing, silently leaving stale bindings
cargo run --bin uniffi-bindgen -- generate --language kotlin --out-dir kotlin-bindings --no-format \
    crates/yggmail-mobile/src/yggmail_mobile.udl

Copy the results into the Android project:

Built file Android project
target/aarch64-linux-android/release/libyggmail_mobile.so app/src/main/jniLibs/arm64-v8a/
target/armv7-linux-androideabi/release/libyggmail_mobile.so app/src/main/jniLibs/armeabi-v7a/
target/x86_64-linux-android/release/libyggmail_mobile.so app/src/main/jniLibs/x86_64/
target/i686-linux-android/release/libyggmail_mobile.so app/src/main/jniLibs/x86/
kotlin-bindings/uniffi/yggmail_mobile/yggmail_mobile.kt app/src/main/java/uniffi/yggmail_mobile/
val mobile = YggmailMobile()
mobile.setPassword(password)
mobile.start(YggmailConfig(
    privateKey = "",              // empty: load or create the key in the database
    peers = listOf("tcp://host:port"),
    listen = emptyList(),
    groupPassword = "",
    databasePath = "/data/data/.../yggmail.db",
    smtpPort = 1025u, imapPort = 1143u,
    passwordHash = passwordSha256Hex,
))
mobile.startSmtp(1025u, passwordSha256Hex)
mobile.startImap(1143u, passwordSha256Hex)
// ...
mobile.stop()

Layout

crates/yggmail/src/
  quic/      mail over QUIC (outbound and inbound)
  ymp/       legacy inbound protocol of 1.9.0 nodes
  peer/      outbound queue sender, inbound receiver
  smtp/      local SMTP server
  imap/      local IMAP server (on imap-rs)
  storage/   SQLite, at-rest encryption
crates/yggmail-mobile/   UniFFI library for Android

Tests

cargo test --workspace

License

MPL-2.0