Sovite.Maildir (sovite v0.2.0)

Copy Markdown View Source

Delivers messages into Maildir folders (https://cr.yp.to/proto/maildir.html).

{:ok, path} = Sovite.Maildir.deliver("/var/vmail/example.com/alice", chunks)

The message is written to a unique file in tmp/, flushed to disk, and then renamed into new/, so a reader never sees a partial message and a crash leaves at most a stray file in tmp/. The folder and its cur/, new/, and tmp/ subdirectories are created as needed, with mode 0700; message files get mode 0600.

File names are <seconds>.M<microseconds>P<pid>Q<counter>.<host>,S=<size>, with the size extension Dovecot and Courier read.

Summary

Types

Why a delivery failed: a file error, or an exception raised while reading data.

Functions

Creates the Maildir at dir, if it does not exist yet.

Writes data (an enumerable of iodata) as a new message in the Maildir at dir.

Types

error()

@type error() :: File.posix() | {:read, Exception.t()}

Why a delivery failed: a file error, or an exception raised while reading data.

Functions

create(dir)

@spec create(Path.t()) :: :ok | {:error, File.posix()}

Creates the Maildir at dir, if it does not exist yet.

deliver(dir, data, opts \\ [])

@spec deliver(Path.t(), Enumerable.t(), keyword()) ::
  {:ok, Path.t()} | {:error, error()}

Writes data (an enumerable of iodata) as a new message in the Maildir at dir.

Options

  • :hostname - the host part of the file name. Defaults to this machine's name.