add "mox localserve" subcommand, for running mox locally for email-related testing/developing

localserve creates a config for listening on localhost for
imap/smtp/submission/http, on port numbers 1000 + the common service port
numbers. all incoming email is accepted (if checks pass), and a few pattern in
localparts are recognized and result in delivery errors.
This commit is contained in:
Mechiel Lukkien
2023-03-12 10:38:02 +01:00
parent bddc8e4062
commit 0099197d00
12 changed files with 694 additions and 108 deletions

31
doc.go
View File

@ -27,6 +27,7 @@ low-maintenance self-hosted email.
mox import mbox accountname mailboxname mbox
mox export maildir dst-dir account-path [mailbox]
mox export mbox dst-dir account-path [mailbox]
mox localserve
mox help [command ...]
mox config test
mox config dnscheck domain
@ -291,6 +292,36 @@ otherwise reconstructing the original could lose a ">".
usage: mox export mbox dst-dir account-path [mailbox]
# 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.
All incoming email is accepted (if checks pass), unless the recipient localpart
ends with:
- "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")
# mox help
Prints help about matching commands.