# S-nail

> Command-line mail program that implements POSIX mailx, with MIME, IMAP, POP3, SMTP, Maildir and S/MIME support.

S-nail is a fork of Heirloom mailx and works as a POSIX mailx(1) for reading and sending mail from a line-oriented prompt or from scripts. It speaks POP3, IMAP and SMTP itself, reads mbox and Maildir folders, and supports S/MIME signing and encryption. Upstream notes that its IMAP code is kept at an older level and should be used with care. It suits users who want a classic mail command for shell scripts and quick terminal use.

- Type: Email client
- Interface: Command-line tools and prompts
- Systems: Runs on Linux, macOS and BSD, on Windows through WSL. Not available for Android.
- Language: C
- License: ISC and BSD 2-Clause and BSD 3-Clause and BSD 4-Clause (ISC AND BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause)
- Latest version: 14.9.25
- Background: Fork of Heirloom mailx, which descends from BSD Mail
- Maintained: yes
- Website: https://www.sdaoden.eu/code.html#s-mailx
- Source: https://git.sdaoden.eu/browse/s-nail.git
- Documentation: https://www.sdaoden.eu/code-nail.html

## Install

### Linux

Native.

- apt: `sudo apt install s-nail`
- dnf: `sudo dnf install s-nail`
- pacman: `sudo pacman -S s-nail`

### macOS

Native.

- Homebrew: `brew install s-nail`

### Windows

Through WSL. No native Windows build; run it in WSL.

- WSL: `sudo apt install s-nail`

### BSD

Native.

- FreeBSD pkg: `pkg install s-nail`
- OpenBSD: `pkg_add s-nail`

### Android

Not supported. No Termux package.

## Protocols

- IMAP: Yes
- POP3: Yes
- SMTP: Yes
- JMAP: No
- Maildir: Yes
- mbox: Yes
- notmuch: No

## Features

- OpenPGP: No
- S/MIME: Yes
- OAuth2 sign-in: via script
- Threads: Yes
- Search: built-in message specifications and the search command; IMAP SEARCH on IMAP folders
- HTML mail: built-in tag-soup filter or external viewer via mailcap
- Mouse: No
- Multiple accounts: Yes
- Offline use: IMAP cache with disconnected mode
- Calendar: No
- Contacts: aliases via the alias command
- Vim-style keys: No
- Configuration: ~/.mailrc command file

## Pros

- Drop-in POSIX mailx, so it works in existing shell scripts and cron jobs.
- Built-in SMTP, POP3 and IMAP with TLS; no separate sync or send tool needed.
- S/MIME signing and encryption are built in.

## Cons

- Line-oriented prompt instead of a full-screen interface.
- No built-in OpenPGP; upstream documents a gpg pipe workaround only.
- IMAP support is kept at an older code level and upstream advises care.

## Use S-nail with Forward Email

File: `~/.mailrc`

```
# ~/.mailrc  (start with: s-nail -A forwardemail)
set v15-compat
set tls-verify=strict
# Read credentials from an encrypted netrc file
set netrc-lookup netrc-pipe='gpg -qd ~/.netrc.gpg'

account forwardemail {
  set from='Your Name <you@example.com>'
  set folder=imaps://you%40example.com@imap.forwardemail.net \
      inbox=imaps://you%40example.com@imap.forwardemail.net/INBOX \
      record="+Sent Mail"
  set mta=smtps://you%40example.com@smtp.forwardemail.net:465
}

# Decrypted contents of ~/.netrc.gpg:
# machine imap.forwardemail.net login you@example.com password YOUR-GENERATED-PASSWORD
# machine smtp.forwardemail.net login you@example.com password YOUR-GENERATED-PASSWORD
# For POP3 instead of IMAP: set inbox=pop3s://you%40example.com@pop3.forwardemail.net
```

| Protocol | Server | Port | Security |
| --- | --- | --- | --- |
| IMAP | imap.forwardemail.net | 993 | SSL/TLS |
| POP3 | pop3.forwardemail.net | 995 | SSL/TLS |
| SMTP | smtp.forwardemail.net | 465 | SSL/TLS |
| SMTP | smtp.forwardemail.net | 587 | STARTTLS |

Username: your full alias address. Password: the one from Generate Password next to the alias. Folders: INBOX, Drafts, Sent Mail, Trash, Spam and Archive.

## Questions

### Does S-nail work on Windows?

Not natively. It runs in Windows Subsystem for Linux (WSL). No native Windows build; run it in WSL.

### Does S-nail support IMAP?

Yes, S-nail connects to IMAP servers directly.

### Is S-nail open source?

Yes, under the ISC and BSD 2-Clause and BSD 3-Clause and BSD 4-Clause.

### How do I use S-nail with Forward Email?

Use the config in the Forward Email section on this page, saved as ~/.mailrc, and replace the address and password with your own.

## Sources

- https://www.sdaoden.eu/code.html
- https://www.sdaoden.eu/code-nail.html
- https://git.sdaoden.eu/browse/s-nail.git
- https://git.sdaoden.eu/browse/s-nail.git/tree/COPYING?h=v14.9.25
- https://git.sdaoden.eu/browse/s-nail.git/tree/README?h=v14.9.25
- https://git.sdaoden.eu/browse/s-nail.git/tree/nail.1?h=v14.9.25
- https://git.sdaoden.eu/browse/s-nail.git/tree/make.rc?h=v14.9.25
- https://packages.debian.org/trixie/s-nail
- https://mdapi.fedoraproject.org/rawhide/pkg/s-nail
- https://archlinux.org/packages/core/x86_64/s-nail/
- https://formulae.brew.sh/formula/s-nail
- https://github.com/freebsd/freebsd-ports/blob/main/mail/s-nail/Makefile
- https://github.com/openbsd/ports/blob/master/mail/s-nail/Makefile
- https://github.com/termux/termux-packages/tree/master/packages
- https://github.com/forwardemail/forwardemail.net/blob/master/helpers/ensure-default-mailboxes.js
