2023-01-30 16:27:06 +03:00
|
|
|
/*
|
implement dnssec-awareness throughout code, and dane for incoming/outgoing mail delivery
the vendored dns resolver code is a copy of the go stdlib dns resolver, with
awareness of the "authentic data" (i.e. dnssec secure) added, as well as support
for enhanced dns errors, and looking up tlsa records (for dane). ideally it
would be upstreamed, but the chances seem slim.
dnssec-awareness is added to all packages, e.g. spf, dkim, dmarc, iprev. their
dnssec status is added to the Received message headers for incoming email.
but the main reason to add dnssec was for implementing dane. with dane, the
verification of tls certificates can be done through certificates/public keys
published in dns (in the tlsa records). this only makes sense (is trustworthy)
if those dns records can be verified to be authentic.
mox now applies dane to delivering messages over smtp. mox already implemented
mta-sts for webpki/pkix-verification of certificates against the (large) pool
of CA's, and still enforces those policies when present. but it now also checks
for dane records, and will verify those if present. if dane and mta-sts are
both absent, the regular opportunistic tls with starttls is still done. and the
fallback to plaintext is also still done.
mox also makes it easy to setup dane for incoming deliveries, so other servers
can deliver with dane tls certificate verification. the quickstart now
generates private keys that are used when requesting certificates with acme.
the private keys are pre-generated because they must be static and known during
setup, because their public keys must be published in tlsa records in dns.
autocert would generate private keys on its own, so had to be forked to add the
option to provide the private key when requesting a new certificate. hopefully
upstream will accept the change and we can drop the fork.
with this change, using the quickstart to setup a new mox instance, the checks
at internet.nl result in a 100% score, provided the domain is dnssec-signed and
the network doesn't have any issues.
2023-10-10 13:09:35 +03:00
|
|
|
Command mox is a modern, secure, full-featured, open source mail server for
|
2023-01-30 16:27:06 +03:00
|
|
|
low-maintenance self-hosted email.
|
|
|
|
|
2024-01-10 18:48:53 +03:00
|
|
|
Mox is started with the "serve" subcommand, but mox also has many other
|
|
|
|
subcommands.
|
|
|
|
|
|
|
|
Many of those commands talk to a running mox instance, through the ctl file in
|
|
|
|
the data directory. Specify the configuration file (that holds the path to the
|
|
|
|
data directory) through the -config flag or MOXCONF environment variable.
|
|
|
|
|
|
|
|
Commands that don't talk to a running mox instance are often for
|
|
|
|
testing/debugging email functionality. For example for parsing an email message,
|
|
|
|
or looking up SPF/DKIM/DMARC records.
|
|
|
|
|
|
|
|
Below is the usage information as printed by the command when started without
|
|
|
|
any parameters. Followed by the help and usage information for each command.
|
|
|
|
|
|
|
|
# Usage
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-03-12 17:16:01 +03:00
|
|
|
mox [-config config/mox.conf] [-pedantic] ...
|
2023-01-30 16:27:06 +03:00
|
|
|
mox serve
|
2023-03-05 17:40:26 +03:00
|
|
|
mox quickstart [-existing-webserver] [-hostname host] user@domain [user | uid]
|
2023-01-30 16:27:06 +03:00
|
|
|
mox stop
|
2023-09-23 18:18:49 +03:00
|
|
|
mox setaccountpassword account
|
2023-01-30 16:27:06 +03:00
|
|
|
mox setadminpassword
|
|
|
|
mox loglevels [level [pkg]]
|
|
|
|
mox queue list
|
new feature: when delivering messages from the queue, make it possible to use a "transport"
the default transport is still just "direct delivery", where we connect to the
destination domain's MX servers.
other transports are:
- regular smtp without authentication, this is relaying to a smarthost.
- submission with authentication, e.g. to a third party email sending service.
- direct delivery, but with with connections going through a socks proxy. this
can be helpful if your ip is blocked, you need to get email out, and you have
another IP that isn't blocked.
keep in mind that for all of the above, appropriate SPF/DKIM settings have to
be configured. the "dnscheck" for a domain does a check for any SOCKS IP in the
SPF record. SPF for smtp/submission (ranges? includes?) and any DKIM
requirements cannot really be checked.
which transport is used can be configured through routes. routes can be set on
an account, a domain, or globally. the routes are evaluated in that order, with
the first match selecting the transport. these routes are evaluated for each
delivery attempt. common selection criteria are recipient domain and sender
domain, but also which delivery attempt this is. you could configured mox to
attempt sending through a 3rd party from the 4th attempt onwards.
routes and transports are optional. if no route matches, or an empty/zero
transport is selected, normal direct delivery is done.
we could already "submit" emails with 3rd party accounts with "sendmail". but
we now support more SASL authentication mechanisms with SMTP (not only PLAIN,
but also SCRAM-SHA-256, SCRAM-SHA-1 and CRAM-MD5), which sendmail now also
supports. sendmail will use the most secure mechanism supported by the server,
or the explicitly configured mechanism.
for issue #36 by dmikushin. also based on earlier discussion on hackernews.
2023-06-16 19:38:28 +03:00
|
|
|
mox queue kick [-id id] [-todomain domain] [-recipient address] [-transport transport]
|
2023-01-30 16:27:06 +03:00
|
|
|
mox queue drop [-id id] [-todomain domain] [-recipient address]
|
|
|
|
mox queue dump id
|
|
|
|
mox import maildir accountname mailboxname maildir
|
|
|
|
mox import mbox accountname mailboxname mbox
|
2023-02-14 00:37:25 +03:00
|
|
|
mox export maildir dst-dir account-path [mailbox]
|
|
|
|
mox export mbox dst-dir account-path [mailbox]
|
2023-03-12 12:38:02 +03:00
|
|
|
mox localserve
|
2023-01-30 16:27:06 +03:00
|
|
|
mox help [command ...]
|
add a "backup" subcommand to make consistent backups, and a "verifydata" subcommand to verify a backup before restoring, and add tests for future upgrades
the backup command will make consistent snapshots of all the database files. i
had been copying the db files before, and it usually works. but if the file is
modified during the backup, it is inconsistent and is likely to generate errors
when reading (can be at any moment in the future, when reading some db page).
"mox backup" opens the database file and writes out a copy in a transaction.
it also duplicates the message files.
before doing a restore, you could run "mox verifydata" on the to-be-restored
"data" directory. it check the database files, and compares the message files
with the database.
the new "gentestdata" subcommand generates a basic "data" directory, with a
queue and a few accounts. we will use it in the future along with "verifydata"
to test upgrades from old version to the latest version. both when going to the
next version, and when skipping several versions. the script test-upgrades.sh
executes these tests and doesn't do anything at the moment, because no releases
have this subcommand yet.
inspired by a failed upgrade attempt of a pre-release version.
2023-05-26 20:26:51 +03:00
|
|
|
mox backup dest-dir
|
|
|
|
mox verifydata data-dir
|
2023-01-30 16:27:06 +03:00
|
|
|
mox config test
|
|
|
|
mox config dnscheck domain
|
|
|
|
mox config dnsrecords domain
|
|
|
|
mox config describe-domains >domains.conf
|
|
|
|
mox config describe-static >mox.conf
|
|
|
|
mox config account add account address
|
|
|
|
mox config account rm account
|
|
|
|
mox config address add address account
|
|
|
|
mox config address rm address
|
|
|
|
mox config domain add domain account [localpart]
|
|
|
|
mox config domain rm domain
|
2023-02-03 15:47:44 +03:00
|
|
|
mox config describe-sendmail >/etc/moxsubmit.conf
|
change mox to start as root, bind to network sockets, then drop to regular unprivileged mox user
makes it easier to run on bsd's, where you cannot (easily?) let non-root users
bind to ports <1024. starting as root also paves the way for future improvements
with privilege separation.
unfortunately, this requires changes to how you start mox. though mox will help
by automatically fix up dir/file permissions/ownership.
if you start mox from the systemd unit file, you should update it so it starts
as root and adds a few additional capabilities:
# first update the mox binary, then, as root:
./mox config printservice >mox.service
systemctl daemon-reload
systemctl restart mox
journalctl -f -u mox &
# you should see mox start up, with messages about fixing permissions on dirs/files.
if you used the recommended config/ and data/ directory, in a directory just for
mox, and with the mox user called "mox", this should be enough.
if you don't want mox to modify dir/file permissions, set "NoFixPermissions:
true" in mox.conf.
if you named the mox user something else than mox, e.g. "_mox", add "User: _mox"
to mox.conf.
if you created a shared service user as originally suggested, you may want to
get rid of that as it is no longer useful and may get in the way. e.g. if you
had /home/service/mox with a "service" user, that service user can no longer
access any files: only mox and root can.
this also adds scripts for building mox docker images for alpine-supported
platforms.
the "restart" subcommand has been removed. it wasn't all that useful and got in
the way.
and another change: when adding a domain while mtasts isn't enabled, don't add
the per-domain mtasts config, as it would cause failure to add the domain.
based on report from setting up mox on openbsd from mteege.
and based on issue #3. thanks for the feedback!
2023-02-27 14:19:55 +03:00
|
|
|
mox config printservice >mox.service
|
implement dnssec-awareness throughout code, and dane for incoming/outgoing mail delivery
the vendored dns resolver code is a copy of the go stdlib dns resolver, with
awareness of the "authentic data" (i.e. dnssec secure) added, as well as support
for enhanced dns errors, and looking up tlsa records (for dane). ideally it
would be upstreamed, but the chances seem slim.
dnssec-awareness is added to all packages, e.g. spf, dkim, dmarc, iprev. their
dnssec status is added to the Received message headers for incoming email.
but the main reason to add dnssec was for implementing dane. with dane, the
verification of tls certificates can be done through certificates/public keys
published in dns (in the tlsa records). this only makes sense (is trustworthy)
if those dns records can be verified to be authentic.
mox now applies dane to delivering messages over smtp. mox already implemented
mta-sts for webpki/pkix-verification of certificates against the (large) pool
of CA's, and still enforces those policies when present. but it now also checks
for dane records, and will verify those if present. if dane and mta-sts are
both absent, the regular opportunistic tls with starttls is still done. and the
fallback to plaintext is also still done.
mox also makes it easy to setup dane for incoming deliveries, so other servers
can deliver with dane tls certificate verification. the quickstart now
generates private keys that are used when requesting certificates with acme.
the private keys are pre-generated because they must be static and known during
setup, because their public keys must be published in tlsa records in dns.
autocert would generate private keys on its own, so had to be forked to add the
option to provide the private key when requesting a new certificate. hopefully
upstream will accept the change and we can drop the fork.
with this change, using the quickstart to setup a new mox instance, the checks
at internet.nl result in a 100% score, provided the domain is dnssec-signed and
the network doesn't have any issues.
2023-10-10 13:09:35 +03:00
|
|
|
mox config ensureacmehostprivatekeys
|
2023-03-04 02:49:02 +03:00
|
|
|
mox example [name]
|
2023-01-30 16:27:06 +03:00
|
|
|
mox checkupdate
|
|
|
|
mox cid cid
|
|
|
|
mox clientconfig domain
|
implement dnssec-awareness throughout code, and dane for incoming/outgoing mail delivery
the vendored dns resolver code is a copy of the go stdlib dns resolver, with
awareness of the "authentic data" (i.e. dnssec secure) added, as well as support
for enhanced dns errors, and looking up tlsa records (for dane). ideally it
would be upstreamed, but the chances seem slim.
dnssec-awareness is added to all packages, e.g. spf, dkim, dmarc, iprev. their
dnssec status is added to the Received message headers for incoming email.
but the main reason to add dnssec was for implementing dane. with dane, the
verification of tls certificates can be done through certificates/public keys
published in dns (in the tlsa records). this only makes sense (is trustworthy)
if those dns records can be verified to be authentic.
mox now applies dane to delivering messages over smtp. mox already implemented
mta-sts for webpki/pkix-verification of certificates against the (large) pool
of CA's, and still enforces those policies when present. but it now also checks
for dane records, and will verify those if present. if dane and mta-sts are
both absent, the regular opportunistic tls with starttls is still done. and the
fallback to plaintext is also still done.
mox also makes it easy to setup dane for incoming deliveries, so other servers
can deliver with dane tls certificate verification. the quickstart now
generates private keys that are used when requesting certificates with acme.
the private keys are pre-generated because they must be static and known during
setup, because their public keys must be published in tlsa records in dns.
autocert would generate private keys on its own, so had to be forked to add the
option to provide the private key when requesting a new certificate. hopefully
upstream will accept the change and we can drop the fork.
with this change, using the quickstart to setup a new mox instance, the checks
at internet.nl result in a 100% score, provided the domain is dnssec-signed and
the network doesn't have any issues.
2023-10-10 13:09:35 +03:00
|
|
|
mox dane dial host:port
|
|
|
|
mox dane dialmx domain [destination-host]
|
|
|
|
mox dane makerecord usage selector matchtype [certificate.pem | publickey.pem | privatekey.pem]
|
|
|
|
mox dns lookup [ptr | mx | cname | ips | a | aaaa | ns | txt | srv | tlsa] name
|
2023-10-13 09:59:35 +03:00
|
|
|
mox dkim gened25519 >$selector._domainkey.$domain.ed25519.privatekey.pkcs8.pem
|
|
|
|
mox dkim genrsa >$selector._domainkey.$domain.rsa2048.privatekey.pkcs8.pem
|
2023-01-30 16:27:06 +03:00
|
|
|
mox dkim lookup selector domain
|
|
|
|
mox dkim txt <$selector._domainkey.$domain.key.pkcs8.pem
|
|
|
|
mox dkim verify message
|
2023-03-07 23:59:55 +03:00
|
|
|
mox dkim sign message
|
2023-01-30 16:27:06 +03:00
|
|
|
mox dmarc lookup domain
|
|
|
|
mox dmarc parsereportmsg message ...
|
|
|
|
mox dmarc verify remoteip mailfromaddress helodomain < message
|
2023-08-23 15:27:21 +03:00
|
|
|
mox dmarc checkreportaddrs domain
|
2023-01-30 16:27:06 +03:00
|
|
|
mox dnsbl check zone ip
|
|
|
|
mox dnsbl checkhealth zone
|
|
|
|
mox mtasts lookup domain
|
improve training of junk filter
before, we used heuristics to decide when to train/untrain a message as junk or
nonjunk: the message had to be seen, be in certain mailboxes. then if a message
was marked as junk, it was junk. and otherwise it was nonjunk. this wasn't good
enough: you may want to keep some messages around as neither junk or nonjunk.
and that wasn't possible.
ideally, we would just look at the imap $Junk and $NotJunk flags. the problem
is that mail clients don't set these flags, or don't make it easy. thunderbird
can set the flags based on its own bayesian filter. it has a shortcut for
marking Junk and moving it to the junk folder (good), but the counterpart of
notjunk only marks a message as notjunk without showing in the UI that it was
marked as notjunk. there is also no "move and mark as notjunk" mechanism. e.g.
"archive" does not mark a message as notjunk. ios mail and mutt don't appear to
have any way to see or change the $Junk and $NotJunk flags.
what email clients do have is the ability to move messages to other
mailboxes/folders. so mox now has a mechanism that allows you to configure
mailboxes that automatically set $Junk or $NotJunk (or clear both) when a
message is moved/copied/delivered to that folder. e.g. a mailbox called junk or
spam or rejects marks its messags as junk. inbox, postmaster, dmarc, tlsrpt,
neutral* mark their messages as neither junk or notjunk. other folders mark
their messages as notjunk. e.g. list/*, archive. this functionality is
optional, but enabled with the quickstart and for new accounts.
also, mox now keeps track of the previous training of a message and will only
untrain/train if needed. before, there probably have been duplicate or missing
(un)trainings.
this also includes a new subcommand "retrain" to recreate the junkfilter for an
account. you should run it after updating to this version. and you should
probably also modify your account config to include the AutomaticJunkFlags.
2023-02-12 01:00:12 +03:00
|
|
|
mox retrain accountname
|
2023-01-30 16:27:06 +03:00
|
|
|
mox sendmail [-Fname] [ignoredflags] [-t] [<message]
|
|
|
|
mox spf check domain ip
|
|
|
|
mox spf lookup domain
|
|
|
|
mox spf parse txtrecord
|
|
|
|
mox tlsrpt lookup domain
|
|
|
|
mox tlsrpt parsereportmsg message ...
|
|
|
|
mox version
|
2023-08-10 13:29:46 +03:00
|
|
|
mox bumpuidvalidity account [mailbox]
|
|
|
|
mox reassignuids account [mailboxid]
|
|
|
|
mox fixuidmeta account
|
|
|
|
mox fixmsgsize [account]
|
|
|
|
mox reparse [account]
|
|
|
|
mox ensureparsed account
|
|
|
|
mox recalculatemailboxcounts account
|
|
|
|
mox message parse message.eml
|
implement message threading in backend and webmail
we match messages to their parents based on the "references" and "in-reply-to"
headers (requiring the same base subject), and in absense of those headers we
also by only base subject (against messages received max 4 weeks ago).
we store a threadid with messages. all messages in a thread have the same
threadid. messages also have a "thread parent ids", which holds all id's of
parent messages up to the thread root. then there is "thread missing link",
which is set when a referenced immediate parent wasn't found (but possibly
earlier ancestors can still be found and will be in thread parent ids".
threads can be muted: newly delivered messages are automatically marked as
read/seen. threads can be marked as collapsed: if set, the webmail collapses
the thread to a single item in the basic threading view (default is to expand
threads). the muted and collapsed fields are copied from their parent on
message delivery.
the threading is implemented in the webmail. the non-threading mode still works
as before. the new default threading mode "unread" automatically expands only
the threads with at least one unread (not seen) meessage. the basic threading
mode "on" expands all threads except when explicitly collapsed (as saved in the
thread collapsed field). new shortcuts for navigation/interaction threads have
been added, e.g. go to previous/next thread root, toggle collapse/expand of
thread (or double click), toggle mute of thread. some previous shortcuts have
changed, see the help for details.
the message threading are added with an explicit account upgrade step,
automatically started when an account is opened. the upgrade is done in the
background because it will take too long for large mailboxes to block account
operations. the upgrade takes two steps: 1. updating all message records in the
database to add a normalized message-id and thread base subject (with "re:",
"fwd:" and several other schemes stripped). 2. going through all messages in
the database again, reading the "references" and "in-reply-to" headers from
disk, and matching against their parents. this second step is also done at the
end of each import of mbox/maildir mailboxes. new deliveries are matched
immediately against other existing messages, currently no attempt is made to
rematch previously delivered messages (which could be useful for related
messages being delivered out of order).
the threading is not yet exposed over imap.
2023-09-13 09:51:50 +03:00
|
|
|
mox reassignthreads [account]
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
# mox serve
|
|
|
|
|
|
|
|
Start mox, serving SMTP/IMAP/HTTPS.
|
|
|
|
|
|
|
|
Incoming email is accepted over SMTP. Email can be retrieved by users using
|
|
|
|
IMAP. HTTP listeners are started for the admin/account web interfaces, and for
|
|
|
|
automated TLS configuration. Missing essential TLS certificates are immediately
|
|
|
|
requested, other TLS certificates are requested on demand.
|
|
|
|
|
make mox compile on windows, without "mox serve" but with working "mox localserve"
getting mox to compile required changing code in only a few places where
package "syscall" was used: for accessing file access times and for umask
handling. an open problem is how to start a process as an unprivileged user on
windows. that's why "mox serve" isn't implemented yet. and just finding a way
to implement it now may not be good enough in the near future: we may want to
starting using a more complete privilege separation approach, with a process
handling sensitive tasks (handling private keys, authentication), where we may
want to pass file descriptors between processes. how would that work on
windows?
anyway, getting mox to compile for windows doesn't mean it works properly on
windows. the largest issue: mox would normally open a file, rename or remove
it, and finally close it. this happens during message delivery. that doesn't
work on windows, the rename/remove would fail because the file is still open.
so this commit swaps many "remove" and "close" calls. renames are a longer
story: message delivery had two ways to deliver: with "consuming" the
(temporary) message file (which would rename it to its final destination), and
without consuming (by hardlinking the file, falling back to copying). the last
delivery to a recipient of a message (and the only one in the common case of a
single recipient) would consume the message, and the earlier recipients would
not. during delivery, the already open message file was used, to parse the
message. we still want to use that open message file, and the caller now stays
responsible for closing it, but we no longer try to rename (consume) the file.
we always hardlink (or copy) during delivery (this works on windows), and the
caller is responsible for closing and removing (in that order) the original
temporary file. this does cost one syscall more. but it makes the delivery code
(responsibilities) a bit simpler.
there is one more obvious issue: the file system path separator. mox already
used the "filepath" package to join paths in many places, but not everywhere.
and it still used strings with slashes for local file access. with this commit,
the code now uses filepath.FromSlash for path strings with slashes, uses
"filepath" in a few more places where it previously didn't. also switches from
"filepath" to regular "path" package when handling mailbox names in a few
places, because those always use forward slashes, regardless of local file
system conventions. windows can handle forward slashes when opening files, so
test code that passes path strings with forward slashes straight to go stdlib
file i/o functions are left unchanged to reduce code churn. the regular
non-test code, or test code that uses path strings in places other than
standard i/o functions, does have the paths converted for consistent paths
(otherwise we would end up with paths with mixed forward/backward slashes in
log messages).
windows cannot dup a listening socket. for "mox localserve", it isn't
important, and we can work around the issue. the current approach for "mox
serve" (forking a process and passing file descriptors of listening sockets on
"privileged" ports) won't work on windows. perhaps it isn't needed on windows,
and any user can listen on "privileged" ports? that would be welcome.
on windows, os.Open cannot open a directory, so we cannot call Sync on it after
message delivery. a cursory internet search indicates that directories cannot
be synced on windows. the story is probably much more nuanced than that, with
long deep technical details/discussions/disagreement/confusion, like on unix.
for "mox localserve" we can get away with making syncdir a no-op.
2023-10-14 11:54:07 +03:00
|
|
|
Only implemented on unix systems, not Windows.
|
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
usage: mox serve
|
|
|
|
|
|
|
|
# mox quickstart
|
|
|
|
|
|
|
|
Quickstart generates configuration files and prints instructions to quickly set up a mox instance.
|
|
|
|
|
change mox to start as root, bind to network sockets, then drop to regular unprivileged mox user
makes it easier to run on bsd's, where you cannot (easily?) let non-root users
bind to ports <1024. starting as root also paves the way for future improvements
with privilege separation.
unfortunately, this requires changes to how you start mox. though mox will help
by automatically fix up dir/file permissions/ownership.
if you start mox from the systemd unit file, you should update it so it starts
as root and adds a few additional capabilities:
# first update the mox binary, then, as root:
./mox config printservice >mox.service
systemctl daemon-reload
systemctl restart mox
journalctl -f -u mox &
# you should see mox start up, with messages about fixing permissions on dirs/files.
if you used the recommended config/ and data/ directory, in a directory just for
mox, and with the mox user called "mox", this should be enough.
if you don't want mox to modify dir/file permissions, set "NoFixPermissions:
true" in mox.conf.
if you named the mox user something else than mox, e.g. "_mox", add "User: _mox"
to mox.conf.
if you created a shared service user as originally suggested, you may want to
get rid of that as it is no longer useful and may get in the way. e.g. if you
had /home/service/mox with a "service" user, that service user can no longer
access any files: only mox and root can.
this also adds scripts for building mox docker images for alpine-supported
platforms.
the "restart" subcommand has been removed. it wasn't all that useful and got in
the way.
and another change: when adding a domain while mtasts isn't enabled, don't add
the per-domain mtasts config, as it would cause failure to add the domain.
based on report from setting up mox on openbsd from mteege.
and based on issue #3. thanks for the feedback!
2023-02-27 14:19:55 +03:00
|
|
|
Quickstart writes configuration files, prints initial admin and account
|
|
|
|
passwords, DNS records you should create. If you run it on Linux it writes a
|
|
|
|
systemd service file and prints commands to enable and start mox as service.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
change mox to start as root, bind to network sockets, then drop to regular unprivileged mox user
makes it easier to run on bsd's, where you cannot (easily?) let non-root users
bind to ports <1024. starting as root also paves the way for future improvements
with privilege separation.
unfortunately, this requires changes to how you start mox. though mox will help
by automatically fix up dir/file permissions/ownership.
if you start mox from the systemd unit file, you should update it so it starts
as root and adds a few additional capabilities:
# first update the mox binary, then, as root:
./mox config printservice >mox.service
systemctl daemon-reload
systemctl restart mox
journalctl -f -u mox &
# you should see mox start up, with messages about fixing permissions on dirs/files.
if you used the recommended config/ and data/ directory, in a directory just for
mox, and with the mox user called "mox", this should be enough.
if you don't want mox to modify dir/file permissions, set "NoFixPermissions:
true" in mox.conf.
if you named the mox user something else than mox, e.g. "_mox", add "User: _mox"
to mox.conf.
if you created a shared service user as originally suggested, you may want to
get rid of that as it is no longer useful and may get in the way. e.g. if you
had /home/service/mox with a "service" user, that service user can no longer
access any files: only mox and root can.
this also adds scripts for building mox docker images for alpine-supported
platforms.
the "restart" subcommand has been removed. it wasn't all that useful and got in
the way.
and another change: when adding a domain while mtasts isn't enabled, don't add
the per-domain mtasts config, as it would cause failure to add the domain.
based on report from setting up mox on openbsd from mteege.
and based on issue #3. thanks for the feedback!
2023-02-27 14:19:55 +03:00
|
|
|
The user or uid is optional, defaults to "mox", and is the user or uid/gid mox
|
|
|
|
will run as after initialization.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-03-05 17:40:26 +03:00
|
|
|
Quickstart assumes mox will run on the machine you run quickstart on and uses
|
|
|
|
its host name and public IPs. On many systems the hostname is not a fully
|
|
|
|
qualified domain name, but only the first dns "label", e.g. "mail" in case of
|
|
|
|
"mail.example.org". If so, quickstart does a reverse DNS lookup to find the
|
|
|
|
hostname, and as fallback uses the label plus the domain of the email address
|
|
|
|
you specified. Use flag -hostname to explicitly specify the hostname mox will
|
|
|
|
run on.
|
|
|
|
|
2023-03-04 02:49:02 +03:00
|
|
|
Mox is by far easiest to operate if you let it listen on port 443 (HTTPS) and
|
|
|
|
80 (HTTP). TLS will be fully automatic with ACME with Let's Encrypt.
|
|
|
|
|
|
|
|
You can run mox along with an existing webserver, but because of MTA-STS and
|
|
|
|
autoconfig, you'll need to forward HTTPS traffic for two domains to mox. Run
|
|
|
|
"mox quickstart -existing-webserver ..." to generate configuration files and
|
|
|
|
instructions for configuring mox along with an existing webserver.
|
|
|
|
|
|
|
|
But please first consider configuring mox on port 443. It can itself serve
|
|
|
|
domains with HTTP/HTTPS, including with automatic TLS with ACME, is easily
|
|
|
|
configured through both configuration files and admin web interface, and can act
|
|
|
|
as a reverse proxy (and static file server for that matter), so you can forward
|
|
|
|
traffic to your existing backend applications. Look for "WebHandlers:" in the
|
|
|
|
output of "mox config describe-domains" and see the output of "mox example
|
|
|
|
webhandlers".
|
|
|
|
|
2023-03-05 17:40:26 +03:00
|
|
|
usage: mox quickstart [-existing-webserver] [-hostname host] user@domain [user | uid]
|
2023-03-04 02:49:02 +03:00
|
|
|
-existing-webserver
|
|
|
|
use if a webserver is already running, so mox won't listen on port 80 and 443; you'll have to provide tls certificates/keys, and configure the existing webserver as reverse proxy, forwarding requests to mox.
|
2023-03-05 17:40:26 +03:00
|
|
|
-hostname string
|
|
|
|
hostname mox will run on, by default the hostname of the machine quickstart runs on; if specified, the IPs for the hostname are configured for the public listener
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
# mox stop
|
|
|
|
|
|
|
|
Shut mox down, giving connections maximum 3 seconds to stop before closing them.
|
|
|
|
|
|
|
|
While shutting down, new IMAP and SMTP connections will get a status response
|
|
|
|
indicating temporary unavailability. Existing connections will get a 3 second
|
|
|
|
period to finish their transaction and shut down. Under normal circumstances,
|
|
|
|
only IMAP has long-living connections, with the IDLE command to get notified of
|
|
|
|
new mail deliveries.
|
|
|
|
|
|
|
|
usage: mox stop
|
|
|
|
|
|
|
|
# mox setaccountpassword
|
|
|
|
|
|
|
|
Set new password an account.
|
|
|
|
|
2023-02-05 23:25:48 +03:00
|
|
|
The password is read from stdin. Secrets derived from the password, but not the
|
|
|
|
password itself, are stored in the account database. The stored secrets are for
|
|
|
|
authentication with: scram-sha-256, scram-sha-1, cram-md5, plain text (bcrypt
|
|
|
|
hash).
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-09-23 18:18:49 +03:00
|
|
|
The parameter is an account name, as configured under Accounts in domains.conf
|
|
|
|
and as present in the data/accounts/ directory, not a configured email address
|
|
|
|
for an account.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-09-23 18:18:49 +03:00
|
|
|
usage: mox setaccountpassword account
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
# mox setadminpassword
|
|
|
|
|
|
|
|
Set a new admin password, for the web interface.
|
|
|
|
|
|
|
|
The password is read from stdin. Its bcrypt hash is stored in a file named
|
|
|
|
"adminpasswd" in the configuration directory.
|
|
|
|
|
|
|
|
usage: mox setadminpassword
|
|
|
|
|
|
|
|
# mox loglevels
|
|
|
|
|
|
|
|
Print the log levels, or set a new default log level, or a level for the given package.
|
|
|
|
|
|
|
|
By default, a single log level applies to all logging in mox. But for each
|
|
|
|
"pkg", an overriding log level can be configured. Examples of packages:
|
|
|
|
smtpserver, smtpclient, queue, imapserver, spf, dkim, dmarc, junk, message,
|
|
|
|
etc.
|
|
|
|
|
2023-02-06 17:17:46 +03:00
|
|
|
Specify a pkg and an empty level to clear the configured level for a package.
|
|
|
|
|
2023-02-03 22:33:19 +03:00
|
|
|
Valid labels: error, info, debug, trace, traceauth, tracedata.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
usage: mox loglevels [level [pkg]]
|
|
|
|
|
|
|
|
# mox queue list
|
|
|
|
|
|
|
|
List messages in the delivery queue.
|
|
|
|
|
|
|
|
This prints the message with its ID, last and next delivery attempts, last
|
|
|
|
error.
|
|
|
|
|
|
|
|
usage: mox queue list
|
|
|
|
|
|
|
|
# mox queue kick
|
|
|
|
|
|
|
|
Schedule matching messages in the queue for immediate delivery.
|
|
|
|
|
|
|
|
Messages deliveries are normally attempted with exponential backoff. The first
|
|
|
|
retry after 7.5 minutes, and doubling each time. Kicking messages sets their
|
|
|
|
next scheduled attempt to now, it can cause delivery to fail earlier than
|
|
|
|
without rescheduling.
|
|
|
|
|
new feature: when delivering messages from the queue, make it possible to use a "transport"
the default transport is still just "direct delivery", where we connect to the
destination domain's MX servers.
other transports are:
- regular smtp without authentication, this is relaying to a smarthost.
- submission with authentication, e.g. to a third party email sending service.
- direct delivery, but with with connections going through a socks proxy. this
can be helpful if your ip is blocked, you need to get email out, and you have
another IP that isn't blocked.
keep in mind that for all of the above, appropriate SPF/DKIM settings have to
be configured. the "dnscheck" for a domain does a check for any SOCKS IP in the
SPF record. SPF for smtp/submission (ranges? includes?) and any DKIM
requirements cannot really be checked.
which transport is used can be configured through routes. routes can be set on
an account, a domain, or globally. the routes are evaluated in that order, with
the first match selecting the transport. these routes are evaluated for each
delivery attempt. common selection criteria are recipient domain and sender
domain, but also which delivery attempt this is. you could configured mox to
attempt sending through a 3rd party from the 4th attempt onwards.
routes and transports are optional. if no route matches, or an empty/zero
transport is selected, normal direct delivery is done.
we could already "submit" emails with 3rd party accounts with "sendmail". but
we now support more SASL authentication mechanisms with SMTP (not only PLAIN,
but also SCRAM-SHA-256, SCRAM-SHA-1 and CRAM-MD5), which sendmail now also
supports. sendmail will use the most secure mechanism supported by the server,
or the explicitly configured mechanism.
for issue #36 by dmikushin. also based on earlier discussion on hackernews.
2023-06-16 19:38:28 +03:00
|
|
|
With the -transport flag, future delivery attempts are done using the specified
|
|
|
|
transport. Transports can be configured in mox.conf, e.g. to submit to a remote
|
|
|
|
queue over SMTP.
|
|
|
|
|
|
|
|
usage: mox queue kick [-id id] [-todomain domain] [-recipient address] [-transport transport]
|
2023-01-30 16:27:06 +03:00
|
|
|
-id int
|
|
|
|
id of message in queue
|
|
|
|
-recipient string
|
|
|
|
recipient email address
|
|
|
|
-todomain string
|
|
|
|
destination domain of messages
|
new feature: when delivering messages from the queue, make it possible to use a "transport"
the default transport is still just "direct delivery", where we connect to the
destination domain's MX servers.
other transports are:
- regular smtp without authentication, this is relaying to a smarthost.
- submission with authentication, e.g. to a third party email sending service.
- direct delivery, but with with connections going through a socks proxy. this
can be helpful if your ip is blocked, you need to get email out, and you have
another IP that isn't blocked.
keep in mind that for all of the above, appropriate SPF/DKIM settings have to
be configured. the "dnscheck" for a domain does a check for any SOCKS IP in the
SPF record. SPF for smtp/submission (ranges? includes?) and any DKIM
requirements cannot really be checked.
which transport is used can be configured through routes. routes can be set on
an account, a domain, or globally. the routes are evaluated in that order, with
the first match selecting the transport. these routes are evaluated for each
delivery attempt. common selection criteria are recipient domain and sender
domain, but also which delivery attempt this is. you could configured mox to
attempt sending through a 3rd party from the 4th attempt onwards.
routes and transports are optional. if no route matches, or an empty/zero
transport is selected, normal direct delivery is done.
we could already "submit" emails with 3rd party accounts with "sendmail". but
we now support more SASL authentication mechanisms with SMTP (not only PLAIN,
but also SCRAM-SHA-256, SCRAM-SHA-1 and CRAM-MD5), which sendmail now also
supports. sendmail will use the most secure mechanism supported by the server,
or the explicitly configured mechanism.
for issue #36 by dmikushin. also based on earlier discussion on hackernews.
2023-06-16 19:38:28 +03:00
|
|
|
-transport string
|
|
|
|
transport to use for the next delivery
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
# mox queue drop
|
|
|
|
|
|
|
|
Remove matching messages from the queue.
|
|
|
|
|
|
|
|
Dangerous operation, this completely removes the message. If you want to store
|
|
|
|
the message, use "queue dump" before removing.
|
|
|
|
|
|
|
|
usage: mox queue drop [-id id] [-todomain domain] [-recipient address]
|
|
|
|
-id int
|
|
|
|
id of message in queue
|
|
|
|
-recipient string
|
|
|
|
recipient email address
|
|
|
|
-todomain string
|
|
|
|
destination domain of messages
|
|
|
|
|
|
|
|
# mox queue dump
|
|
|
|
|
|
|
|
Dump a message from the queue.
|
|
|
|
|
|
|
|
The message is printed to stdout and is in standard internet mail format.
|
|
|
|
|
|
|
|
usage: mox queue dump id
|
|
|
|
|
|
|
|
# mox import maildir
|
|
|
|
|
|
|
|
Import a maildir into an account.
|
|
|
|
|
2023-10-12 16:46:29 +03:00
|
|
|
The mbox/maildir archive is accessed and imported by the running mox process, so
|
|
|
|
it must have access to the archive files. The default suggested systemd service
|
|
|
|
file isolates mox from most of the file system, with only the "data/" directory
|
|
|
|
accessible, so you may want to put the mbox/maildir archive files in a
|
|
|
|
directory like "data/import/" to make it available to mox.
|
|
|
|
|
2023-02-16 11:57:27 +03:00
|
|
|
By default, messages will train the junk filter based on their flags and, if
|
|
|
|
"automatic junk flags" configuration is set, based on mailbox naming.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-08-09 10:31:23 +03:00
|
|
|
If the destination mailbox is the Sent mailbox, the recipients of the messages
|
|
|
|
are added to the message metadata, causing later incoming messages from these
|
|
|
|
recipients to be accepted, unless other reputation signals prevent that.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-02-16 11:57:27 +03:00
|
|
|
Users can also import mailboxes/messages through the account web page by
|
|
|
|
uploading a zip or tgz file with mbox and/or maildirs.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-02-16 11:57:27 +03:00
|
|
|
Mailbox flags, like "seen", "answered", will be imported. An optional
|
|
|
|
dovecot-keywords file can specify additional flags, like Forwarded/Junk/NotJunk.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
usage: mox import maildir accountname mailboxname maildir
|
|
|
|
|
|
|
|
# mox import mbox
|
|
|
|
|
|
|
|
Import an mbox into an account.
|
|
|
|
|
2023-02-16 11:57:27 +03:00
|
|
|
Using mbox is not recommended, maildir is a better defined format.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-10-12 16:46:29 +03:00
|
|
|
The mbox/maildir archive is accessed and imported by the running mox process, so
|
|
|
|
it must have access to the archive files. The default suggested systemd service
|
|
|
|
file isolates mox from most of the file system, with only the "data/" directory
|
|
|
|
accessible, so you may want to put the mbox/maildir archive files in a
|
|
|
|
directory like "data/import/" to make it available to mox.
|
|
|
|
|
2023-02-16 11:57:27 +03:00
|
|
|
By default, messages will train the junk filter based on their flags and, if
|
|
|
|
"automatic junk flags" configuration is set, based on mailbox naming.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-08-09 10:31:23 +03:00
|
|
|
If the destination mailbox is the Sent mailbox, the recipients of the messages
|
|
|
|
are added to the message metadata, causing later incoming messages from these
|
|
|
|
recipients to be accepted, unless other reputation signals prevent that.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-02-16 11:57:27 +03:00
|
|
|
Users can also import mailboxes/messages through the account web page by
|
|
|
|
uploading a zip or tgz file with mbox and/or maildirs.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
usage: mox import mbox accountname mailboxname mbox
|
|
|
|
|
|
|
|
# mox export maildir
|
|
|
|
|
|
|
|
Export one or all mailboxes from an account in maildir format.
|
|
|
|
|
|
|
|
Export bypasses a running mox instance. It opens the account mailbox/message
|
|
|
|
database file directly. This may block if a running mox instance also has the
|
2023-02-13 20:04:05 +03:00
|
|
|
database open, e.g. for IMAP connections. To export from a running instance, use
|
|
|
|
the accounts web page.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-02-14 00:37:25 +03:00
|
|
|
usage: mox export maildir dst-dir account-path [mailbox]
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
# mox export mbox
|
|
|
|
|
|
|
|
Export messages from one or all mailboxes in an account in mbox format.
|
|
|
|
|
|
|
|
Using mbox is not recommended. Maildir is a better format.
|
|
|
|
|
|
|
|
Export bypasses a running mox instance. It opens the account mailbox/message
|
|
|
|
database file directly. This may block if a running mox instance also has the
|
2023-02-13 20:04:05 +03:00
|
|
|
database open, e.g. for IMAP connections. To export from a running instance, use
|
|
|
|
the accounts web page.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-02-14 00:37:25 +03:00
|
|
|
For mbox export, "mboxrd" is used where message lines starting with the magic
|
|
|
|
"From " string are escaped by prepending a >. All ">*From " are escaped,
|
2023-01-30 16:27:06 +03:00
|
|
|
otherwise reconstructing the original could lose a ">".
|
|
|
|
|
2023-02-14 00:37:25 +03:00
|
|
|
usage: mox export mbox dst-dir account-path [mailbox]
|
2023-01-30 16:27:06 +03:00
|
|
|
|
2023-03-12 12:38:02 +03:00
|
|
|
# mox localserve
|
|
|
|
|
|
|
|
Start a local SMTP/IMAP server that accepts all messages, useful when testing/developing software that sends email.
|
|
|
|
|
|
|
|
Localserve starts mox with a configuration suitable for local email-related
|
|
|
|
software development/testing. It listens for SMTP/Submission(s), IMAP(s) and
|
|
|
|
HTTP(s), on the regular port numbers + 1000.
|
|
|
|
|
|
|
|
Data is stored in the system user's configuration directory under
|
|
|
|
"mox-localserve", e.g. $HOME/.config/mox-localserve/ on linux, but can be
|
|
|
|
overridden with the -dir flag. If the directory does not yet exist, it is
|
|
|
|
automatically initialized with configuration files, an account with email
|
|
|
|
address mox@localhost and password moxmoxmox, and a newly generated self-signed
|
|
|
|
TLS certificate.
|
|
|
|
|
2023-03-12 23:42:28 +03:00
|
|
|
All incoming email to any address is accepted (if checks pass), unless the
|
|
|
|
recipient localpart ends with:
|
2023-03-12 12:38:02 +03:00
|
|
|
|
|
|
|
- "temperror": fail with a temporary error code
|
|
|
|
- "permerror": fail with a permanent error code
|
|
|
|
- [45][0-9][0-9]: fail with the specific error code
|
|
|
|
- "timeout": no response (for an hour)
|
|
|
|
|
|
|
|
If the localpart begins with "mailfrom" or "rcptto", the error is returned
|
|
|
|
during those commands instead of during "data".
|
|
|
|
|
|
|
|
usage: mox localserve
|
|
|
|
-dir string
|
|
|
|
configuration storage directory (default "$userconfigdir/mox-localserve")
|
2023-11-02 16:10:04 +03:00
|
|
|
-initonly
|
|
|
|
write configuration files and exit
|
2023-07-01 19:48:29 +03:00
|
|
|
-ip string
|
|
|
|
serve on this ip instead of default 127.0.0.1 and ::1. only used when writing configuration, at first launch.
|
2023-03-12 12:38:02 +03:00
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
# mox help
|
|
|
|
|
|
|
|
Prints help about matching commands.
|
|
|
|
|
|
|
|
If multiple commands match, they are listed along with the first line of their help text.
|
|
|
|
If a single command matches, its usage and full help text is printed.
|
|
|
|
|
|
|
|
usage: mox help [command ...]
|
|
|
|
|
add a "backup" subcommand to make consistent backups, and a "verifydata" subcommand to verify a backup before restoring, and add tests for future upgrades
the backup command will make consistent snapshots of all the database files. i
had been copying the db files before, and it usually works. but if the file is
modified during the backup, it is inconsistent and is likely to generate errors
when reading (can be at any moment in the future, when reading some db page).
"mox backup" opens the database file and writes out a copy in a transaction.
it also duplicates the message files.
before doing a restore, you could run "mox verifydata" on the to-be-restored
"data" directory. it check the database files, and compares the message files
with the database.
the new "gentestdata" subcommand generates a basic "data" directory, with a
queue and a few accounts. we will use it in the future along with "verifydata"
to test upgrades from old version to the latest version. both when going to the
next version, and when skipping several versions. the script test-upgrades.sh
executes these tests and doesn't do anything at the moment, because no releases
have this subcommand yet.
inspired by a failed upgrade attempt of a pre-release version.
2023-05-26 20:26:51 +03:00
|
|
|
# mox backup
|
|
|
|
|
|
|
|
Creates a backup of the data directory.
|
|
|
|
|
|
|
|
Backup creates consistent snapshots of the databases and message files and
|
|
|
|
copies other files in the data directory. Empty directories are not copied.
|
|
|
|
These files can then be stored elsewhere for long-term storage, or used to fall
|
|
|
|
back to should an upgrade fail. Simply copying files in the data directory
|
|
|
|
while mox is running can result in unusable database files.
|
|
|
|
|
|
|
|
Message files never change (they are read-only, though can be removed) and are
|
2023-08-23 15:59:43 +03:00
|
|
|
hard-linked so they don't consume additional space. If hardlinking fails, for
|
add a "backup" subcommand to make consistent backups, and a "verifydata" subcommand to verify a backup before restoring, and add tests for future upgrades
the backup command will make consistent snapshots of all the database files. i
had been copying the db files before, and it usually works. but if the file is
modified during the backup, it is inconsistent and is likely to generate errors
when reading (can be at any moment in the future, when reading some db page).
"mox backup" opens the database file and writes out a copy in a transaction.
it also duplicates the message files.
before doing a restore, you could run "mox verifydata" on the to-be-restored
"data" directory. it check the database files, and compares the message files
with the database.
the new "gentestdata" subcommand generates a basic "data" directory, with a
queue and a few accounts. we will use it in the future along with "verifydata"
to test upgrades from old version to the latest version. both when going to the
next version, and when skipping several versions. the script test-upgrades.sh
executes these tests and doesn't do anything at the moment, because no releases
have this subcommand yet.
inspired by a failed upgrade attempt of a pre-release version.
2023-05-26 20:26:51 +03:00
|
|
|
example when the backup destination directory is on a different file system, a
|
|
|
|
regular copy is made. Using a destination directory like "data/tmp/backup"
|
|
|
|
increases the odds hardlinking succeeds: the default systemd service file
|
|
|
|
specifically mounts the data directory, causing attempts to hardlink outside it
|
|
|
|
to fail with an error about cross-device linking.
|
|
|
|
|
|
|
|
All files in the data directory that aren't recognized (i.e. other than known
|
2023-06-01 12:34:28 +03:00
|
|
|
database files, message files, an acme directory, the "tmp" directory, etc),
|
|
|
|
are stored, but with a warning.
|
add a "backup" subcommand to make consistent backups, and a "verifydata" subcommand to verify a backup before restoring, and add tests for future upgrades
the backup command will make consistent snapshots of all the database files. i
had been copying the db files before, and it usually works. but if the file is
modified during the backup, it is inconsistent and is likely to generate errors
when reading (can be at any moment in the future, when reading some db page).
"mox backup" opens the database file and writes out a copy in a transaction.
it also duplicates the message files.
before doing a restore, you could run "mox verifydata" on the to-be-restored
"data" directory. it check the database files, and compares the message files
with the database.
the new "gentestdata" subcommand generates a basic "data" directory, with a
queue and a few accounts. we will use it in the future along with "verifydata"
to test upgrades from old version to the latest version. both when going to the
next version, and when skipping several versions. the script test-upgrades.sh
executes these tests and doesn't do anything at the moment, because no releases
have this subcommand yet.
inspired by a failed upgrade attempt of a pre-release version.
2023-05-26 20:26:51 +03:00
|
|
|
|
|
|
|
A clean successful backup does not print any output by default. Use the
|
|
|
|
-verbose flag for details, including timing.
|
|
|
|
|
|
|
|
To restore a backup, first shut down mox, move away the old data directory and
|
|
|
|
move an earlier backed up directory in its place, run "mox verifydata",
|
|
|
|
possibly with the "-fix" option, and restart mox. After the restore, you may
|
|
|
|
also want to run "mox bumpuidvalidity" for each account for which messages in a
|
|
|
|
mailbox changed, to force IMAP clients to synchronize mailbox state.
|
|
|
|
|
|
|
|
Before upgrading, to check if the upgrade will likely succeed, first make a
|
|
|
|
backup, then use the new mox binary to run "mox verifydata" on the backup. This
|
|
|
|
can change the backup files (e.g. upgrade database files, move away
|
|
|
|
unrecognized message files), so you should make a new backup before actually
|
|
|
|
upgrading.
|
|
|
|
|
|
|
|
usage: mox backup dest-dir
|
|
|
|
-verbose
|
|
|
|
print progress
|
|
|
|
|
|
|
|
# mox verifydata
|
|
|
|
|
|
|
|
Verify the contents of a data directory, typically of a backup.
|
|
|
|
|
|
|
|
Verifydata checks all database files to see if they are valid BoltDB/bstore
|
|
|
|
databases. It checks that all messages in the database have a corresponding
|
|
|
|
on-disk message file and there are no unrecognized files. If option -fix is
|
|
|
|
specified, unrecognized message files are moved away. This may be needed after
|
|
|
|
a restore, because messages enqueued or delivered in the future may get those
|
|
|
|
message sequence numbers assigned and writing the message file would fail.
|
2023-06-30 18:19:29 +03:00
|
|
|
Consistency of message/mailbox UID, UIDNEXT and UIDVALIDITY is verified as
|
|
|
|
well.
|
add a "backup" subcommand to make consistent backups, and a "verifydata" subcommand to verify a backup before restoring, and add tests for future upgrades
the backup command will make consistent snapshots of all the database files. i
had been copying the db files before, and it usually works. but if the file is
modified during the backup, it is inconsistent and is likely to generate errors
when reading (can be at any moment in the future, when reading some db page).
"mox backup" opens the database file and writes out a copy in a transaction.
it also duplicates the message files.
before doing a restore, you could run "mox verifydata" on the to-be-restored
"data" directory. it check the database files, and compares the message files
with the database.
the new "gentestdata" subcommand generates a basic "data" directory, with a
queue and a few accounts. we will use it in the future along with "verifydata"
to test upgrades from old version to the latest version. both when going to the
next version, and when skipping several versions. the script test-upgrades.sh
executes these tests and doesn't do anything at the moment, because no releases
have this subcommand yet.
inspired by a failed upgrade attempt of a pre-release version.
2023-05-26 20:26:51 +03:00
|
|
|
|
|
|
|
Because verifydata opens the database files, schema upgrades may automatically
|
|
|
|
be applied. This can happen if you use a new mox release. It is useful to run
|
|
|
|
"mox verifydata" with a new binary before attempting an upgrade, but only on a
|
|
|
|
copy of the database files, as made with "mox backup". Before upgrading, make a
|
|
|
|
new backup again since "mox verifydata" may have upgraded the database files,
|
|
|
|
possibly making them potentially no longer readable by the previous version.
|
|
|
|
|
|
|
|
usage: mox verifydata data-dir
|
|
|
|
-fix
|
|
|
|
fix fixable problems, such as moving away message files not referenced by their database
|
2023-08-16 15:36:17 +03:00
|
|
|
-skip-size-check
|
|
|
|
skip the check for message size
|
add a "backup" subcommand to make consistent backups, and a "verifydata" subcommand to verify a backup before restoring, and add tests for future upgrades
the backup command will make consistent snapshots of all the database files. i
had been copying the db files before, and it usually works. but if the file is
modified during the backup, it is inconsistent and is likely to generate errors
when reading (can be at any moment in the future, when reading some db page).
"mox backup" opens the database file and writes out a copy in a transaction.
it also duplicates the message files.
before doing a restore, you could run "mox verifydata" on the to-be-restored
"data" directory. it check the database files, and compares the message files
with the database.
the new "gentestdata" subcommand generates a basic "data" directory, with a
queue and a few accounts. we will use it in the future along with "verifydata"
to test upgrades from old version to the latest version. both when going to the
next version, and when skipping several versions. the script test-upgrades.sh
executes these tests and doesn't do anything at the moment, because no releases
have this subcommand yet.
inspired by a failed upgrade attempt of a pre-release version.
2023-05-26 20:26:51 +03:00
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
# mox config test
|
|
|
|
|
|
|
|
Parses and validates the configuration files.
|
|
|
|
|
|
|
|
If valid, the command exits with status 0. If not valid, all errors encountered
|
|
|
|
are printed.
|
|
|
|
|
|
|
|
usage: mox config test
|
|
|
|
|
|
|
|
# mox config dnscheck
|
|
|
|
|
|
|
|
Check the DNS records with the configuration for the domain, and print any errors/warnings.
|
|
|
|
|
|
|
|
usage: mox config dnscheck domain
|
|
|
|
|
|
|
|
# mox config dnsrecords
|
|
|
|
|
|
|
|
Prints annotated DNS records as zone file that should be created for the domain.
|
|
|
|
|
|
|
|
The zone file can be imported into existing DNS software. You should review the
|
|
|
|
DNS records, especially if your domain previously/currently has email
|
|
|
|
configured.
|
|
|
|
|
|
|
|
usage: mox config dnsrecords domain
|
|
|
|
|
|
|
|
# mox config describe-domains
|
|
|
|
|
|
|
|
Prints an annotated empty configuration for use as domains.conf.
|
|
|
|
|
|
|
|
The domains configuration file contains the domains and their configuration,
|
|
|
|
and accounts and their configuration. This includes the configured email
|
|
|
|
addresses. The mox admin web interface, and the mox command line interface, can
|
|
|
|
make changes to this file. Mox automatically reloads this file when it changes.
|
|
|
|
|
|
|
|
Like the static configuration, the example domains.conf printed by this command
|
|
|
|
needs modifications to make it valid.
|
|
|
|
|
|
|
|
usage: mox config describe-domains >domains.conf
|
|
|
|
|
|
|
|
# mox config describe-static
|
|
|
|
|
|
|
|
Prints an annotated empty configuration for use as mox.conf.
|
|
|
|
|
|
|
|
The static configuration file cannot be reloaded while mox is running. Mox has
|
|
|
|
to be restarted for changes to the static configuration file to take effect.
|
|
|
|
|
|
|
|
This configuration file needs modifications to make it valid. For example, it
|
|
|
|
may contain unfinished list items.
|
|
|
|
|
|
|
|
usage: mox config describe-static >mox.conf
|
|
|
|
|
|
|
|
# mox config account add
|
|
|
|
|
|
|
|
Add an account with an email address and reload the configuration.
|
|
|
|
|
|
|
|
Email can be delivered to this address/account. A password has to be configured
|
|
|
|
explicitly, see the setaccountpassword command.
|
|
|
|
|
|
|
|
usage: mox config account add account address
|
|
|
|
|
|
|
|
# mox config account rm
|
|
|
|
|
|
|
|
Remove an account and reload the configuration.
|
|
|
|
|
|
|
|
Email addresses for this account will also be removed, and incoming email for
|
|
|
|
these addresses will be rejected.
|
|
|
|
|
|
|
|
usage: mox config account rm account
|
|
|
|
|
|
|
|
# mox config address add
|
|
|
|
|
|
|
|
Adds an address to an account and reloads the configuration.
|
|
|
|
|
2023-03-29 22:11:43 +03:00
|
|
|
If address starts with a @ (i.e. a missing localpart), this is a catchall
|
|
|
|
address for the domain.
|
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
usage: mox config address add address account
|
|
|
|
|
|
|
|
# mox config address rm
|
|
|
|
|
|
|
|
Remove an address and reload the configuration.
|
|
|
|
|
2023-03-29 22:11:43 +03:00
|
|
|
Incoming email for this address will be rejected after removing an address.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
usage: mox config address rm address
|
|
|
|
|
|
|
|
# mox config domain add
|
|
|
|
|
|
|
|
Adds a new domain to the configuration and reloads the configuration.
|
|
|
|
|
|
|
|
The account is used for the postmaster mailboxes the domain, including as DMARC and
|
|
|
|
TLS reporting. Localpart is the "username" at the domain for this account. If
|
|
|
|
must be set if and only if account does not yet exist.
|
|
|
|
|
|
|
|
usage: mox config domain add domain account [localpart]
|
|
|
|
|
|
|
|
# mox config domain rm
|
|
|
|
|
|
|
|
Remove a domain from the configuration and reload the configuration.
|
|
|
|
|
|
|
|
This is a dangerous operation. Incoming email delivery for this domain will be
|
|
|
|
rejected.
|
|
|
|
|
|
|
|
usage: mox config domain rm domain
|
|
|
|
|
2023-02-03 15:47:44 +03:00
|
|
|
# mox config describe-sendmail
|
|
|
|
|
|
|
|
Describe configuration for mox when invoked as sendmail.
|
|
|
|
|
|
|
|
usage: mox config describe-sendmail >/etc/moxsubmit.conf
|
|
|
|
|
change mox to start as root, bind to network sockets, then drop to regular unprivileged mox user
makes it easier to run on bsd's, where you cannot (easily?) let non-root users
bind to ports <1024. starting as root also paves the way for future improvements
with privilege separation.
unfortunately, this requires changes to how you start mox. though mox will help
by automatically fix up dir/file permissions/ownership.
if you start mox from the systemd unit file, you should update it so it starts
as root and adds a few additional capabilities:
# first update the mox binary, then, as root:
./mox config printservice >mox.service
systemctl daemon-reload
systemctl restart mox
journalctl -f -u mox &
# you should see mox start up, with messages about fixing permissions on dirs/files.
if you used the recommended config/ and data/ directory, in a directory just for
mox, and with the mox user called "mox", this should be enough.
if you don't want mox to modify dir/file permissions, set "NoFixPermissions:
true" in mox.conf.
if you named the mox user something else than mox, e.g. "_mox", add "User: _mox"
to mox.conf.
if you created a shared service user as originally suggested, you may want to
get rid of that as it is no longer useful and may get in the way. e.g. if you
had /home/service/mox with a "service" user, that service user can no longer
access any files: only mox and root can.
this also adds scripts for building mox docker images for alpine-supported
platforms.
the "restart" subcommand has been removed. it wasn't all that useful and got in
the way.
and another change: when adding a domain while mtasts isn't enabled, don't add
the per-domain mtasts config, as it would cause failure to add the domain.
based on report from setting up mox on openbsd from mteege.
and based on issue #3. thanks for the feedback!
2023-02-27 14:19:55 +03:00
|
|
|
# mox config printservice
|
|
|
|
|
|
|
|
Prints a systemd unit service file for mox.
|
|
|
|
|
|
|
|
This is the same file as generated using quickstart. If the systemd service file
|
|
|
|
has changed with a newer version of mox, use this command to generate an up to
|
|
|
|
date version.
|
|
|
|
|
|
|
|
usage: mox config printservice >mox.service
|
|
|
|
|
implement dnssec-awareness throughout code, and dane for incoming/outgoing mail delivery
the vendored dns resolver code is a copy of the go stdlib dns resolver, with
awareness of the "authentic data" (i.e. dnssec secure) added, as well as support
for enhanced dns errors, and looking up tlsa records (for dane). ideally it
would be upstreamed, but the chances seem slim.
dnssec-awareness is added to all packages, e.g. spf, dkim, dmarc, iprev. their
dnssec status is added to the Received message headers for incoming email.
but the main reason to add dnssec was for implementing dane. with dane, the
verification of tls certificates can be done through certificates/public keys
published in dns (in the tlsa records). this only makes sense (is trustworthy)
if those dns records can be verified to be authentic.
mox now applies dane to delivering messages over smtp. mox already implemented
mta-sts for webpki/pkix-verification of certificates against the (large) pool
of CA's, and still enforces those policies when present. but it now also checks
for dane records, and will verify those if present. if dane and mta-sts are
both absent, the regular opportunistic tls with starttls is still done. and the
fallback to plaintext is also still done.
mox also makes it easy to setup dane for incoming deliveries, so other servers
can deliver with dane tls certificate verification. the quickstart now
generates private keys that are used when requesting certificates with acme.
the private keys are pre-generated because they must be static and known during
setup, because their public keys must be published in tlsa records in dns.
autocert would generate private keys on its own, so had to be forked to add the
option to provide the private key when requesting a new certificate. hopefully
upstream will accept the change and we can drop the fork.
with this change, using the quickstart to setup a new mox instance, the checks
at internet.nl result in a 100% score, provided the domain is dnssec-signed and
the network doesn't have any issues.
2023-10-10 13:09:35 +03:00
|
|
|
# mox config ensureacmehostprivatekeys
|
|
|
|
|
|
|
|
Ensure host private keys exist for TLS listeners with ACME.
|
|
|
|
|
|
|
|
In mox.conf, each listener can have TLS configured. Long-lived private key files
|
|
|
|
can be specified, which will be used when requesting ACME certificates.
|
|
|
|
Configuring these private keys makes it feasible to publish DANE TLSA records
|
|
|
|
for the corresponding public keys in DNS, protected with DNSSEC, allowing TLS
|
|
|
|
certificate verification without depending on a list of Certificate Authorities
|
|
|
|
(CAs). Previous versions of mox did not pre-generate private keys for use with
|
|
|
|
ACME certificates, but would generate private keys on-demand. By explicitly
|
|
|
|
configuring private keys, they will not change automatedly with new
|
|
|
|
certificates, and the DNS TLSA records stay valid.
|
|
|
|
|
|
|
|
This command looks for listeners in mox.conf with TLS with ACME configured. For
|
|
|
|
each missing host private key (of type rsa-2048 and ecdsa-p256) a key is written
|
|
|
|
to config/hostkeys/. If a certificate exists in the ACME "cache", its private
|
|
|
|
key is copied. Otherwise a new private key is generated. Snippets for manually
|
|
|
|
updating/editing mox.conf are printed.
|
|
|
|
|
|
|
|
After running this command, and updating mox.conf, run "mox config dnsrecords"
|
|
|
|
for a domain and create the TLSA DNS records it suggests to enable DANE.
|
|
|
|
|
|
|
|
usage: mox config ensureacmehostprivatekeys
|
|
|
|
|
2023-03-04 02:49:02 +03:00
|
|
|
# mox example
|
2023-03-01 00:12:27 +03:00
|
|
|
|
|
|
|
List available examples, or print a specific example.
|
|
|
|
|
2023-03-04 02:49:02 +03:00
|
|
|
usage: mox example [name]
|
2023-03-01 00:12:27 +03:00
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
# mox checkupdate
|
|
|
|
|
|
|
|
Check if a newer version of mox is available.
|
|
|
|
|
|
|
|
A single DNS TXT lookup to _updates.xmox.nl tells if a new version is
|
|
|
|
available. If so, a changelog is fetched from https://updates.xmox.nl, and the
|
implement dnssec-awareness throughout code, and dane for incoming/outgoing mail delivery
the vendored dns resolver code is a copy of the go stdlib dns resolver, with
awareness of the "authentic data" (i.e. dnssec secure) added, as well as support
for enhanced dns errors, and looking up tlsa records (for dane). ideally it
would be upstreamed, but the chances seem slim.
dnssec-awareness is added to all packages, e.g. spf, dkim, dmarc, iprev. their
dnssec status is added to the Received message headers for incoming email.
but the main reason to add dnssec was for implementing dane. with dane, the
verification of tls certificates can be done through certificates/public keys
published in dns (in the tlsa records). this only makes sense (is trustworthy)
if those dns records can be verified to be authentic.
mox now applies dane to delivering messages over smtp. mox already implemented
mta-sts for webpki/pkix-verification of certificates against the (large) pool
of CA's, and still enforces those policies when present. but it now also checks
for dane records, and will verify those if present. if dane and mta-sts are
both absent, the regular opportunistic tls with starttls is still done. and the
fallback to plaintext is also still done.
mox also makes it easy to setup dane for incoming deliveries, so other servers
can deliver with dane tls certificate verification. the quickstart now
generates private keys that are used when requesting certificates with acme.
the private keys are pre-generated because they must be static and known during
setup, because their public keys must be published in tlsa records in dns.
autocert would generate private keys on its own, so had to be forked to add the
option to provide the private key when requesting a new certificate. hopefully
upstream will accept the change and we can drop the fork.
with this change, using the quickstart to setup a new mox instance, the checks
at internet.nl result in a 100% score, provided the domain is dnssec-signed and
the network doesn't have any issues.
2023-10-10 13:09:35 +03:00
|
|
|
individual entries verified with a builtin public key. The changelog is
|
2023-01-30 16:27:06 +03:00
|
|
|
printed.
|
|
|
|
|
|
|
|
usage: mox checkupdate
|
|
|
|
|
|
|
|
# mox cid
|
|
|
|
|
|
|
|
Turn an ID from a Received header into a cid, for looking up in logs.
|
|
|
|
|
|
|
|
A cid is essentially a connection counter initialized when mox starts. Each log
|
|
|
|
line contains a cid. Received headers added by mox contain a unique ID that can
|
|
|
|
be decrypted to a cid by admin of a mox instance only.
|
|
|
|
|
|
|
|
usage: mox cid cid
|
|
|
|
|
|
|
|
# mox clientconfig
|
|
|
|
|
|
|
|
Print the configuration for email clients for a domain.
|
|
|
|
|
|
|
|
Sending email is typically not done on the SMTP port 25, but on submission
|
|
|
|
ports 465 (with TLS) and 587 (without initial TLS, but usually added to the
|
|
|
|
connection with STARTTLS). For IMAP, the port with TLS is 993 and without is
|
|
|
|
143.
|
|
|
|
|
|
|
|
Without TLS/STARTTLS, passwords are sent in clear text, which should only be
|
|
|
|
configured over otherwise secured connections, like a VPN.
|
|
|
|
|
|
|
|
usage: mox clientconfig domain
|
|
|
|
|
implement dnssec-awareness throughout code, and dane for incoming/outgoing mail delivery
the vendored dns resolver code is a copy of the go stdlib dns resolver, with
awareness of the "authentic data" (i.e. dnssec secure) added, as well as support
for enhanced dns errors, and looking up tlsa records (for dane). ideally it
would be upstreamed, but the chances seem slim.
dnssec-awareness is added to all packages, e.g. spf, dkim, dmarc, iprev. their
dnssec status is added to the Received message headers for incoming email.
but the main reason to add dnssec was for implementing dane. with dane, the
verification of tls certificates can be done through certificates/public keys
published in dns (in the tlsa records). this only makes sense (is trustworthy)
if those dns records can be verified to be authentic.
mox now applies dane to delivering messages over smtp. mox already implemented
mta-sts for webpki/pkix-verification of certificates against the (large) pool
of CA's, and still enforces those policies when present. but it now also checks
for dane records, and will verify those if present. if dane and mta-sts are
both absent, the regular opportunistic tls with starttls is still done. and the
fallback to plaintext is also still done.
mox also makes it easy to setup dane for incoming deliveries, so other servers
can deliver with dane tls certificate verification. the quickstart now
generates private keys that are used when requesting certificates with acme.
the private keys are pre-generated because they must be static and known during
setup, because their public keys must be published in tlsa records in dns.
autocert would generate private keys on its own, so had to be forked to add the
option to provide the private key when requesting a new certificate. hopefully
upstream will accept the change and we can drop the fork.
with this change, using the quickstart to setup a new mox instance, the checks
at internet.nl result in a 100% score, provided the domain is dnssec-signed and
the network doesn't have any issues.
2023-10-10 13:09:35 +03:00
|
|
|
# mox dane dial
|
|
|
|
|
|
|
|
Dial the address using TLS with certificate verification using DANE.
|
|
|
|
|
|
|
|
Data is copied between connection and stdin/stdout until either side closes the
|
|
|
|
connection.
|
|
|
|
|
|
|
|
usage: mox dane dial host:port
|
|
|
|
-usages string
|
|
|
|
allowed usages for dane, comma-separated list (default "pkix-ta,pkix-ee,dane-ta,dane-ee")
|
|
|
|
|
|
|
|
# mox dane dialmx
|
|
|
|
|
|
|
|
Connect to MX server for domain using STARTTLS verified with DANE.
|
|
|
|
|
|
|
|
If no destination host is specified, regular delivery logic is used to find the
|
|
|
|
hosts to attempt delivery too. This involves following CNAMEs for the domain,
|
|
|
|
looking up MX records, and possibly falling back to the domain name itself as
|
|
|
|
host.
|
|
|
|
|
|
|
|
If a destination host is specified, that is the only candidate host considered
|
|
|
|
for dialing.
|
|
|
|
|
|
|
|
With a list of destinations gathered, each is dialed until a successful SMTP
|
|
|
|
session verified with DANE has been initialized, including EHLO and STARTTLS
|
|
|
|
commands.
|
|
|
|
|
|
|
|
Once connected, data is copied between connection and stdin/stdout, until
|
|
|
|
either side closes the connection.
|
|
|
|
|
|
|
|
This command follows the same logic as delivery attempts made from the queue,
|
|
|
|
sharing most of its code.
|
|
|
|
|
|
|
|
usage: mox dane dialmx domain [destination-host]
|
|
|
|
-ehlohostname string
|
|
|
|
hostname to send in smtp ehlo command (default "localhost")
|
|
|
|
|
|
|
|
# mox dane makerecord
|
|
|
|
|
|
|
|
Print TLSA record for given certificate/key and parameters.
|
|
|
|
|
|
|
|
Valid values:
|
|
|
|
- usage: pkix-ta (0), pkix-ee (1), dane-ta (2), dane-ee (3)
|
|
|
|
- selector: cert (0), spki (1)
|
|
|
|
- matchtype: full (0), sha2-256 (1), sha2-512 (2)
|
|
|
|
|
|
|
|
Common DANE TLSA record parameters are: dane-ee spki sha2-256, or 3 1 1,
|
|
|
|
followed by a sha2-256 hash of the DER-encoded "SPKI" (subject public key info)
|
|
|
|
from the certificate. An example DNS zone file entry:
|
|
|
|
|
2023-10-13 09:16:46 +03:00
|
|
|
_25._tcp.example.com. TLSA 3 1 1 133b919c9d65d8b1488157315327334ead8d83372db57465ecabf53ee5748aee
|
implement dnssec-awareness throughout code, and dane for incoming/outgoing mail delivery
the vendored dns resolver code is a copy of the go stdlib dns resolver, with
awareness of the "authentic data" (i.e. dnssec secure) added, as well as support
for enhanced dns errors, and looking up tlsa records (for dane). ideally it
would be upstreamed, but the chances seem slim.
dnssec-awareness is added to all packages, e.g. spf, dkim, dmarc, iprev. their
dnssec status is added to the Received message headers for incoming email.
but the main reason to add dnssec was for implementing dane. with dane, the
verification of tls certificates can be done through certificates/public keys
published in dns (in the tlsa records). this only makes sense (is trustworthy)
if those dns records can be verified to be authentic.
mox now applies dane to delivering messages over smtp. mox already implemented
mta-sts for webpki/pkix-verification of certificates against the (large) pool
of CA's, and still enforces those policies when present. but it now also checks
for dane records, and will verify those if present. if dane and mta-sts are
both absent, the regular opportunistic tls with starttls is still done. and the
fallback to plaintext is also still done.
mox also makes it easy to setup dane for incoming deliveries, so other servers
can deliver with dane tls certificate verification. the quickstart now
generates private keys that are used when requesting certificates with acme.
the private keys are pre-generated because they must be static and known during
setup, because their public keys must be published in tlsa records in dns.
autocert would generate private keys on its own, so had to be forked to add the
option to provide the private key when requesting a new certificate. hopefully
upstream will accept the change and we can drop the fork.
with this change, using the quickstart to setup a new mox instance, the checks
at internet.nl result in a 100% score, provided the domain is dnssec-signed and
the network doesn't have any issues.
2023-10-10 13:09:35 +03:00
|
|
|
|
|
|
|
The first usable information from the pem file is used to compose the TLSA
|
|
|
|
record. In case of selector "cert", a certificate is required. Otherwise the
|
|
|
|
"subject public key info" (spki) of the first certificate or public or private
|
|
|
|
key (pkcs#8, pkcs#1 or ec private key) is used.
|
|
|
|
|
|
|
|
usage: mox dane makerecord usage selector matchtype [certificate.pem | publickey.pem | privatekey.pem]
|
|
|
|
|
|
|
|
# mox dns lookup
|
|
|
|
|
|
|
|
Lookup DNS name of given type.
|
|
|
|
|
|
|
|
Lookup always prints whether the response was DNSSEC-protected.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
|
|
|
mox dns lookup ptr 1.1.1.1
|
|
|
|
mox dns lookup mx xmox.nl
|
|
|
|
mox dns lookup txt _dmarc.xmox.nl.
|
|
|
|
mox dns lookup tlsa _25._tcp.xmox.nl
|
|
|
|
|
|
|
|
usage: mox dns lookup [ptr | mx | cname | ips | a | aaaa | ns | txt | srv | tlsa] name
|
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
# mox dkim gened25519
|
|
|
|
|
|
|
|
Generate a new ed25519 key for use with DKIM.
|
|
|
|
|
|
|
|
Ed25519 keys are much smaller than RSA keys of comparable cryptographic
|
|
|
|
strength. This is convenient because of maximum DNS message sizes. At the time
|
|
|
|
of writing, not many mail servers appear to support ed25519 DKIM keys though,
|
|
|
|
so it is recommended to sign messages with both RSA and ed25519 keys.
|
|
|
|
|
2023-10-13 09:59:35 +03:00
|
|
|
usage: mox dkim gened25519 >$selector._domainkey.$domain.ed25519.privatekey.pkcs8.pem
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
# mox dkim genrsa
|
|
|
|
|
|
|
|
Generate a new 2048 bit RSA private key for use with DKIM.
|
|
|
|
|
|
|
|
The generated file is in PEM format, and has a comment it is generated for use
|
|
|
|
with DKIM, by mox.
|
|
|
|
|
2023-10-13 09:59:35 +03:00
|
|
|
usage: mox dkim genrsa >$selector._domainkey.$domain.rsa2048.privatekey.pkcs8.pem
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
# mox dkim lookup
|
|
|
|
|
|
|
|
Lookup and print the DKIM record for the selector at the domain.
|
|
|
|
|
|
|
|
usage: mox dkim lookup selector domain
|
|
|
|
|
|
|
|
# mox dkim txt
|
|
|
|
|
|
|
|
Print a DKIM DNS TXT record with the public key derived from the private key read from stdin.
|
|
|
|
|
|
|
|
The DNS should be configured as a TXT record at $selector._domainkey.$domain.
|
|
|
|
|
|
|
|
usage: mox dkim txt <$selector._domainkey.$domain.key.pkcs8.pem
|
|
|
|
|
|
|
|
# mox dkim verify
|
|
|
|
|
|
|
|
Verify the DKIM signatures in a message and print the results.
|
|
|
|
|
|
|
|
The message is parsed, and the DKIM-Signature headers are validated. Validation
|
|
|
|
of older messages may fail because the DNS records have been removed or changed
|
|
|
|
by now, or because the signature header may have specified an expiration time
|
|
|
|
that was passed.
|
|
|
|
|
|
|
|
usage: mox dkim verify message
|
|
|
|
|
2023-03-07 23:59:55 +03:00
|
|
|
# mox dkim sign
|
|
|
|
|
|
|
|
Sign a message, adding DKIM-Signature headers based on the domain in the From header.
|
|
|
|
|
|
|
|
The message is parsed, the domain looked up in the configuration files, and
|
|
|
|
DKIM-Signature headers generated. The message is printed with the DKIM-Signature
|
|
|
|
headers prepended.
|
|
|
|
|
|
|
|
usage: mox dkim sign message
|
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
# mox dmarc lookup
|
|
|
|
|
|
|
|
Lookup dmarc policy for domain, a DNS TXT record at _dmarc.<domain>, validate and print it.
|
|
|
|
|
|
|
|
usage: mox dmarc lookup domain
|
|
|
|
|
|
|
|
# mox dmarc parsereportmsg
|
|
|
|
|
|
|
|
Parse a DMARC report from an email message, and print its extracted details.
|
|
|
|
|
|
|
|
DMARC reports are periodically mailed, if requested in the DMARC DNS record of
|
|
|
|
a domain. Reports are sent by mail servers that received messages with our
|
|
|
|
domain in a From header. This may or may not be legatimate email. DMARC reports
|
|
|
|
contain summaries of evaluations of DMARC and DKIM/SPF, which can help
|
|
|
|
understand email deliverability problems.
|
|
|
|
|
|
|
|
usage: mox dmarc parsereportmsg message ...
|
|
|
|
|
|
|
|
# mox dmarc verify
|
|
|
|
|
|
|
|
Parse an email message and evaluate it against the DMARC policy of the domain in the From-header.
|
|
|
|
|
|
|
|
mailfromaddress and helodomain are used for SPF validation. If both are empty,
|
|
|
|
SPF validation is skipped.
|
|
|
|
|
|
|
|
mailfromaddress should be the address used as MAIL FROM in the SMTP session.
|
|
|
|
For DSN messages, that address may be empty. The helo domain was specified at
|
|
|
|
the beginning of the SMTP transaction that delivered the message. These values
|
|
|
|
can be found in message headers.
|
|
|
|
|
|
|
|
usage: mox dmarc verify remoteip mailfromaddress helodomain < message
|
|
|
|
|
2023-08-23 15:27:21 +03:00
|
|
|
# mox dmarc checkreportaddrs
|
|
|
|
|
|
|
|
For each reporting address in the domain's DMARC record, check if it has opted into receiving reports (if needed).
|
|
|
|
|
|
|
|
A DMARC record can request reports about DMARC evaluations to be sent to an
|
|
|
|
email/http address. If the organizational domains of that of the DMARC record
|
|
|
|
and that of the report destination address do not match, the destination
|
|
|
|
address must opt-in to receiving DMARC reports by creating a DMARC record at
|
|
|
|
<dmarcdomain>._report._dmarc.<reportdestdomain>.
|
|
|
|
|
|
|
|
usage: mox dmarc checkreportaddrs domain
|
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
# mox dnsbl check
|
|
|
|
|
|
|
|
Test if IP is in the DNS blocklist of the zone, e.g. bl.spamcop.net.
|
|
|
|
|
|
|
|
If the IP is in the blocklist, an explanation is printed. This is typically a
|
|
|
|
URL with more information.
|
|
|
|
|
|
|
|
usage: mox dnsbl check zone ip
|
|
|
|
|
|
|
|
# mox dnsbl checkhealth
|
|
|
|
|
|
|
|
Check the health of the DNS blocklist represented by zone, e.g. bl.spamcop.net.
|
|
|
|
|
|
|
|
The health of a DNS blocklist can be checked by querying for 127.0.0.1 and
|
|
|
|
127.0.0.2. The second must and the first must not be present.
|
|
|
|
|
|
|
|
usage: mox dnsbl checkhealth zone
|
|
|
|
|
|
|
|
# mox mtasts lookup
|
|
|
|
|
|
|
|
Lookup the MTASTS record and policy for the domain.
|
|
|
|
|
|
|
|
MTA-STS is a mechanism for a domain to specify if it requires TLS connections
|
|
|
|
for delivering email. If a domain has a valid MTA-STS DNS TXT record at
|
|
|
|
_mta-sts.<domain> it signals it implements MTA-STS. A policy can then be
|
|
|
|
fetched at https://mta-sts.<domain>/.well-known/mta-sts.txt. The policy
|
|
|
|
specifies the mode (enforce, testing, none), which MX servers support TLS and
|
|
|
|
should be used, and how long the policy can be cached.
|
|
|
|
|
|
|
|
usage: mox mtasts lookup domain
|
|
|
|
|
improve training of junk filter
before, we used heuristics to decide when to train/untrain a message as junk or
nonjunk: the message had to be seen, be in certain mailboxes. then if a message
was marked as junk, it was junk. and otherwise it was nonjunk. this wasn't good
enough: you may want to keep some messages around as neither junk or nonjunk.
and that wasn't possible.
ideally, we would just look at the imap $Junk and $NotJunk flags. the problem
is that mail clients don't set these flags, or don't make it easy. thunderbird
can set the flags based on its own bayesian filter. it has a shortcut for
marking Junk and moving it to the junk folder (good), but the counterpart of
notjunk only marks a message as notjunk without showing in the UI that it was
marked as notjunk. there is also no "move and mark as notjunk" mechanism. e.g.
"archive" does not mark a message as notjunk. ios mail and mutt don't appear to
have any way to see or change the $Junk and $NotJunk flags.
what email clients do have is the ability to move messages to other
mailboxes/folders. so mox now has a mechanism that allows you to configure
mailboxes that automatically set $Junk or $NotJunk (or clear both) when a
message is moved/copied/delivered to that folder. e.g. a mailbox called junk or
spam or rejects marks its messags as junk. inbox, postmaster, dmarc, tlsrpt,
neutral* mark their messages as neither junk or notjunk. other folders mark
their messages as notjunk. e.g. list/*, archive. this functionality is
optional, but enabled with the quickstart and for new accounts.
also, mox now keeps track of the previous training of a message and will only
untrain/train if needed. before, there probably have been duplicate or missing
(un)trainings.
this also includes a new subcommand "retrain" to recreate the junkfilter for an
account. you should run it after updating to this version. and you should
probably also modify your account config to include the AutomaticJunkFlags.
2023-02-12 01:00:12 +03:00
|
|
|
# mox retrain
|
|
|
|
|
|
|
|
Recreate and retrain the junk filter for the account.
|
|
|
|
|
|
|
|
Useful after having made changes to the junk filter configuration, or if the
|
|
|
|
implementation has changed.
|
|
|
|
|
|
|
|
usage: mox retrain accountname
|
|
|
|
|
2023-01-30 16:27:06 +03:00
|
|
|
# mox sendmail
|
|
|
|
|
|
|
|
Sendmail is a drop-in replacement for /usr/sbin/sendmail to deliver emails sent by unix processes like cron.
|
|
|
|
|
|
|
|
If invoked as "sendmail", it will act as sendmail for sending messages. Its
|
|
|
|
intention is to let processes like cron send emails. Messages are submitted to
|
|
|
|
an actual mail server over SMTP. The destination mail server and credentials are
|
2023-02-03 15:47:44 +03:00
|
|
|
configured in /etc/moxsubmit.conf, see mox config describe-sendmail. The From
|
|
|
|
message header is rewritten to the configured address. When the addressee
|
|
|
|
appears to be a local user, because without @, the message is sent to the
|
|
|
|
configured default address.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
If submitting an email fails, it is added to a directory moxsubmit.failures in
|
|
|
|
the user's home directory.
|
|
|
|
|
|
|
|
Most flags are ignored to fake compatibility with other sendmail
|
2023-03-20 15:25:38 +03:00
|
|
|
implementations. A single recipient or the -t flag with a To-header is required.
|
|
|
|
With the -t flag, Cc and Bcc headers are not handled specially, so Bcc is not
|
|
|
|
removed and the addresses do not receive the email.
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
/etc/moxsubmit.conf should be group-readable and not readable by others and this
|
|
|
|
binary should be setgid that group:
|
|
|
|
|
|
|
|
groupadd moxsubmit
|
|
|
|
install -m 2755 -o root -g moxsubmit mox /usr/sbin/sendmail
|
|
|
|
touch /etc/moxsubmit.conf
|
|
|
|
chown root:moxsubmit /etc/moxsubmit.conf
|
|
|
|
chmod 640 /etc/moxsubmit.conf
|
|
|
|
# edit /etc/moxsubmit.conf
|
|
|
|
|
|
|
|
|
|
|
|
usage: mox sendmail [-Fname] [ignoredflags] [-t] [<message]
|
|
|
|
|
|
|
|
# mox spf check
|
|
|
|
|
|
|
|
Check the status of IP for the policy published in DNS for the domain.
|
|
|
|
|
|
|
|
IPs may be allowed to send for a domain, or disallowed, and several shades in
|
|
|
|
between. If not allowed, an explanation may be provided by the policy. If so,
|
|
|
|
the explanation is printed. The SPF mechanism that matched (if any) is also
|
|
|
|
printed.
|
|
|
|
|
|
|
|
usage: mox spf check domain ip
|
|
|
|
|
|
|
|
# mox spf lookup
|
|
|
|
|
|
|
|
Lookup the SPF record for the domain and print it.
|
|
|
|
|
|
|
|
usage: mox spf lookup domain
|
|
|
|
|
|
|
|
# mox spf parse
|
|
|
|
|
|
|
|
Parse the record as SPF record. If valid, nothing is printed.
|
|
|
|
|
|
|
|
usage: mox spf parse txtrecord
|
|
|
|
|
|
|
|
# mox tlsrpt lookup
|
|
|
|
|
|
|
|
Lookup the TLSRPT record for the domain.
|
|
|
|
|
|
|
|
A TLSRPT record typically contains an email address where reports about TLS
|
|
|
|
connectivity should be sent. Mail servers attempting delivery to our domain
|
|
|
|
should attempt to use TLS. TLSRPT lets them report how many connection
|
|
|
|
successfully used TLS, and how what kind of errors occurred otherwise.
|
|
|
|
|
|
|
|
usage: mox tlsrpt lookup domain
|
|
|
|
|
|
|
|
# mox tlsrpt parsereportmsg
|
|
|
|
|
|
|
|
Parse and print the TLSRPT in the message.
|
|
|
|
|
|
|
|
The report is printed in formatted JSON.
|
|
|
|
|
|
|
|
usage: mox tlsrpt parsereportmsg message ...
|
|
|
|
|
|
|
|
# mox version
|
|
|
|
|
|
|
|
Prints this mox version.
|
|
|
|
|
|
|
|
usage: mox version
|
2023-08-10 13:29:46 +03:00
|
|
|
|
|
|
|
# mox bumpuidvalidity
|
|
|
|
|
|
|
|
Change the IMAP UID validity of the mailbox, causing IMAP clients to refetch messages.
|
|
|
|
|
|
|
|
This can be useful after manually repairing metadata about the account/mailbox.
|
|
|
|
|
|
|
|
Opens account database file directly. Ensure mox does not have the account
|
2023-09-23 13:15:13 +03:00
|
|
|
open, or is not running.
|
2023-08-10 13:29:46 +03:00
|
|
|
|
|
|
|
usage: mox bumpuidvalidity account [mailbox]
|
|
|
|
|
|
|
|
# mox reassignuids
|
|
|
|
|
|
|
|
Reassign UIDs in one mailbox or all mailboxes in an account and bump UID validity, causing IMAP clients to refetch messages.
|
|
|
|
|
|
|
|
Opens account database file directly. Ensure mox does not have the account
|
|
|
|
open, or is not running.
|
|
|
|
|
|
|
|
usage: mox reassignuids account [mailboxid]
|
|
|
|
|
|
|
|
# mox fixuidmeta
|
|
|
|
|
|
|
|
Fix inconsistent UIDVALIDITY and UIDNEXT in messages/mailboxes/account.
|
|
|
|
|
|
|
|
The next UID to use for a message in a mailbox should always be higher than any
|
|
|
|
existing message UID in the mailbox. If it is not, the mailbox UIDNEXT is
|
|
|
|
updated.
|
|
|
|
|
|
|
|
Each mailbox has a UIDVALIDITY sequence number, which should always be lower
|
|
|
|
than the per-account next UIDVALIDITY to use. If it is not, the account next
|
|
|
|
UIDVALIDITY is updated.
|
|
|
|
|
|
|
|
Opens account database file directly. Ensure mox does not have the account
|
|
|
|
open, or is not running.
|
|
|
|
|
|
|
|
usage: mox fixuidmeta account
|
|
|
|
|
|
|
|
# mox fixmsgsize
|
|
|
|
|
|
|
|
Ensure message sizes in the database matching the sum of the message prefix length and on-disk file size.
|
|
|
|
|
|
|
|
Messages with an inconsistent size are also parsed again.
|
|
|
|
|
|
|
|
If an inconsistency is found, you should probably also run "mox
|
|
|
|
bumpuidvalidity" on the mailboxes or entire account to force IMAP clients to
|
|
|
|
refetch messages.
|
|
|
|
|
|
|
|
usage: mox fixmsgsize [account]
|
|
|
|
|
|
|
|
# mox reparse
|
|
|
|
|
|
|
|
# Parse all messages in the account or all accounts again
|
|
|
|
|
|
|
|
Can be useful after upgrading mox with improved message parsing. Messages are
|
|
|
|
parsed in batches, so other access to the mailboxes/messages are not blocked
|
|
|
|
while reparsing all messages.
|
|
|
|
|
|
|
|
usage: mox reparse [account]
|
|
|
|
|
|
|
|
# mox ensureparsed
|
|
|
|
|
|
|
|
Ensure messages in the database have a pre-parsed MIME form in the database.
|
|
|
|
|
|
|
|
usage: mox ensureparsed account
|
|
|
|
-all
|
|
|
|
store new parsed message for all messages
|
|
|
|
|
|
|
|
# mox recalculatemailboxcounts
|
|
|
|
|
2023-12-20 22:54:12 +03:00
|
|
|
Recalculate message counts for all mailboxes in the account, and total message size for quota.
|
2023-08-10 13:29:46 +03:00
|
|
|
|
|
|
|
When a message is added to/removed from a mailbox, or when message flags change,
|
2023-12-20 22:54:12 +03:00
|
|
|
the total, unread, unseen and deleted messages are accounted, the total size of
|
|
|
|
the mailbox, and the total message size for the account. In case of a bug in
|
|
|
|
this accounting, the numbers could become incorrect. This command will find, fix
|
|
|
|
and print them.
|
2023-08-10 13:29:46 +03:00
|
|
|
|
|
|
|
usage: mox recalculatemailboxcounts account
|
|
|
|
|
|
|
|
# mox message parse
|
|
|
|
|
|
|
|
Parse message, print JSON representation.
|
|
|
|
|
|
|
|
usage: mox message parse message.eml
|
implement message threading in backend and webmail
we match messages to their parents based on the "references" and "in-reply-to"
headers (requiring the same base subject), and in absense of those headers we
also by only base subject (against messages received max 4 weeks ago).
we store a threadid with messages. all messages in a thread have the same
threadid. messages also have a "thread parent ids", which holds all id's of
parent messages up to the thread root. then there is "thread missing link",
which is set when a referenced immediate parent wasn't found (but possibly
earlier ancestors can still be found and will be in thread parent ids".
threads can be muted: newly delivered messages are automatically marked as
read/seen. threads can be marked as collapsed: if set, the webmail collapses
the thread to a single item in the basic threading view (default is to expand
threads). the muted and collapsed fields are copied from their parent on
message delivery.
the threading is implemented in the webmail. the non-threading mode still works
as before. the new default threading mode "unread" automatically expands only
the threads with at least one unread (not seen) meessage. the basic threading
mode "on" expands all threads except when explicitly collapsed (as saved in the
thread collapsed field). new shortcuts for navigation/interaction threads have
been added, e.g. go to previous/next thread root, toggle collapse/expand of
thread (or double click), toggle mute of thread. some previous shortcuts have
changed, see the help for details.
the message threading are added with an explicit account upgrade step,
automatically started when an account is opened. the upgrade is done in the
background because it will take too long for large mailboxes to block account
operations. the upgrade takes two steps: 1. updating all message records in the
database to add a normalized message-id and thread base subject (with "re:",
"fwd:" and several other schemes stripped). 2. going through all messages in
the database again, reading the "references" and "in-reply-to" headers from
disk, and matching against their parents. this second step is also done at the
end of each import of mbox/maildir mailboxes. new deliveries are matched
immediately against other existing messages, currently no attempt is made to
rematch previously delivered messages (which could be useful for related
messages being delivered out of order).
the threading is not yet exposed over imap.
2023-09-13 09:51:50 +03:00
|
|
|
|
|
|
|
# mox reassignthreads
|
|
|
|
|
|
|
|
Reassign message threads.
|
|
|
|
|
|
|
|
For all accounts, or optionally only the specified account.
|
|
|
|
|
|
|
|
Threading for all messages in an account is first reset, and new base subject
|
|
|
|
and normalized message-id saved with the message. Then all messages are
|
|
|
|
evaluated and matched against their parents/ancestors.
|
|
|
|
|
|
|
|
Messages are matched based on the References header, with a fall-back to an
|
|
|
|
In-Reply-To header, and if neither is present/valid, based only on base
|
|
|
|
subject.
|
|
|
|
|
|
|
|
A References header typically points to multiple previous messages in a
|
|
|
|
hierarchy. From oldest ancestor to most recent parent. An In-Reply-To header
|
|
|
|
would have only a message-id of the parent message.
|
|
|
|
|
|
|
|
A message is only linked to a parent/ancestor if their base subject is the
|
|
|
|
same. This ensures unrelated replies, with a new subject, are placed in their
|
|
|
|
own thread.
|
|
|
|
|
|
|
|
The base subject is lower cased, has whitespace collapsed to a single
|
|
|
|
space, and some components removed: leading "Re:", "Fwd:", "Fw:", or bracketed
|
|
|
|
tag (that mailing lists often add, e.g. "[listname]"), trailing "(fwd)", or
|
|
|
|
enclosing "[fwd: ...]".
|
|
|
|
|
|
|
|
Messages are linked to all their ancestors. If an intermediate parent/ancestor
|
|
|
|
message is deleted in the future, the message can still be linked to the earlier
|
|
|
|
ancestors. If the direct parent already wasn't available while matching, this is
|
|
|
|
stored as the message having a "missing link" to its stored ancestors.
|
|
|
|
|
|
|
|
usage: mox reassignthreads [account]
|
2023-01-30 16:27:06 +03:00
|
|
|
*/
|
|
|
|
package main
|
|
|
|
|
|
|
|
// NOTE: DO NOT EDIT, this file is generated by gendoc.sh.
|