Sovite.Core.Sendmail (sovite v0.6.0)

Copy Markdown View Source

The sendmail(1), mailq(1), and newaliases(1) commands, for local programs and cron jobs that expect them.

Releases ship bin/sendmail, bin/mailq, and bin/newaliases wrappers that run main/1 with bin/sovite eval; link them where programs look for them (/usr/sbin/sendmail, /usr/bin/mailq, /usr/bin/newaliases).

sendmail [options] [recipient ...] < message
sendmail -t [options] < message
mailq                                       # sendmail -bp
newaliases                                  # sendmail -bi

Sending

The message is read from standard input and sent over SMTP to sendmail.server ([127.0.0.1]:25 by default), a listener that must accept mail from this host: put 127.0.0.1 in smtp.trusted_networks to let local programs send to other domains. The command waits for the server to queue the message, so its exit status says whether that worked: 0, 75 (EX_TEMPFAIL) when the server is down or refused for now, 69 (EX_UNAVAILABLE) when it refused for good, 65 (EX_DATAERR) without recipients, 64 (EX_USAGE) for bad options. Recipients the server refused while it took the message for others are reported on standard error.

Addresses without a domain get @ and sendmail.origin (by default server.hostname). The sender is -f, or the user running the command ($USER or $LOGNAME) at that domain. A missing From:, Date:, or Message-ID: is added, and Bcc: is removed.

Options:

  • -t - also send to the addresses in To:, Cc:, and Bcc:.
  • -f sender, -r sender - the envelope sender. -f <> is the null sender.
  • -F name - the full name for an added From:.
  • -i, -oi - a line with a single . does not end the message.
  • -C path - the config file. Without it, $SOVITE_CONFIG or /etc/sovite/sovite.toml; when it cannot be read (it holds secrets, so it usually is not readable by everyone), the defaults above apply.
  • -bm - send a message (the default); -bp - list the queue; -bi - rebuild the aliases database.
  • -q - accepted for compatibility; the queue runs on its own.
  • -B, -N, -R, -V, -X, -L, -h, -v, -n, -G, -U, and other -o options are accepted and ignored.

-bs, -bv, -bd, and -bD are not supported.

mailq

Lists the messages in the queue as Postfix does: queue ID (* while being delivered, ! when held), size, arrival time, sender, and the recipients still to be delivered with the reason of the last failure. It reads the queue directory, so it must run as root or the user Sovite runs as.

newaliases

Sovite keeps aliases in its database (sovitectl alias), so there is nothing to rebuild: it prints a note and succeeds, so scripts that call it keep working. See sovitectl migrate postfix to import /etc/aliases.

Summary

Functions

Prints the queue in directory as Postfix's mailq does. Returns the exit status.

Runs the command in argv and halts the VM with its exit status.

Runs the command in argv and returns its exit status. Options: :input (an IO device for the message, standard input by default), :env (a map of environment variables, for the user name).

Functions

mailq(directory)

@spec mailq(Path.t()) :: non_neg_integer()

Prints the queue in directory as Postfix's mailq does. Returns the exit status.

main(argv)

@spec main([String.t()]) :: no_return()

Runs the command in argv and halts the VM with its exit status.

run(argv, opts \\ [])

@spec run([String.t()], keyword()) :: non_neg_integer()

Runs the command in argv and returns its exit status. Options: :input (an IO device for the message, standard input by default), :env (a map of environment variables, for the user name).