add webmail
it was far down on the roadmap, but implemented earlier, because it's
interesting, and to help prepare for a jmap implementation. for jmap we need to
implement more client-like functionality than with just imap. internal data
structures need to change. jmap has lots of other requirements, so it's already
a big project. by implementing a webmail now, some of the required data
structure changes become clear and can be made now, so the later jmap
implementation can do things similarly to the webmail code. the webmail
frontend and webmail are written together, making their interface/api much
smaller and simpler than jmap.
one of the internal changes is that we now keep track of per-mailbox
total/unread/unseen/deleted message counts and mailbox sizes. keeping this
data consistent after any change to the stored messages (through the code base)
is tricky, so mox now has a consistency check that verifies the counts are
correct, which runs only during tests, each time an internal account reference
is closed. we have a few more internal "changes" that are propagated for the
webmail frontend (that imap doesn't have a way to propagate on a connection),
like changes to the special-use flags on mailboxes, and used keywords in a
mailbox. more changes that will be required have revealed themselves while
implementing the webmail, and will be implemented next.
the webmail user interface is modeled after the mail clients i use or have
used: thunderbird, macos mail, mutt; and webmails i normally only use for
testing: gmail, proton, yahoo, outlook. a somewhat technical user is assumed,
but still the goal is to make this webmail client easy to use for everyone. the
user interface looks like most other mail clients: a list of mailboxes, a
search bar, a message list view, and message details. there is a top/bottom and
a left/right layout for the list/message view, default is automatic based on
screen size. the panes can be resized by the user. buttons for actions are just
text, not icons. clicking a button briefly shows the shortcut for the action in
the bottom right, helping with learning to operate quickly. any text that is
underdotted has a title attribute that causes more information to be displayed,
e.g. what a button does or a field is about. to highlight potential phishing
attempts, any text (anywhere in the webclient) that switches unicode "blocks"
(a rough approximation to (language) scripts) within a word is underlined
orange. multiple messages can be selected with familiar ui interaction:
clicking while holding control and/or shift keys. keyboard navigation works
with arrows/page up/down and home/end keys, and also with a few basic vi-like
keys for list/message navigation. we prefer showing the text instead of
html (with inlined images only) version of a message. html messages are shown
in an iframe served from an endpoint with CSP headers to prevent dangerous
resources (scripts, external images) from being loaded. the html is also
sanitized, with javascript removed. a user can choose to load external
resources (e.g. images for tracking purposes).
the frontend is just (strict) typescript, no external frameworks. all
incoming/outgoing data is typechecked, both the api request parameters and
response types, and the data coming in over SSE. the types and checking code
are generated with sherpats, which uses the api definitions generated by
sherpadoc based on the Go code. so types from the backend are automatically
propagated to the frontend. since there is no framework to automatically
propagate properties and rerender components, changes coming in over the SSE
connection are propagated explicitly with regular function calls. the ui is
separated into "views", each with a "root" dom element that is added to the
visible document. these views have additional functions for getting changes
propagated, often resulting in the view updating its (internal) ui state (dom).
we keep the frontend compilation simple, it's just a few typescript files that
get compiled (combined and types stripped) into a single js file, no additional
runtime code needed or complicated build processes used. the webmail is served
is served from a compressed, cachable html file that includes style and the
javascript, currently just over 225kb uncompressed, under 60kb compressed (not
minified, including comments). we include the generated js files in the
repository, to keep Go's easily buildable self-contained binaries.
authentication is basic http, as with the account and admin pages. most data
comes in over one long-term SSE connection to the backend. api requests signal
which mailbox/search/messages are requested over the SSE connection. fetching
individual messages, and making changes, are done through api calls. the
operations are similar to imap, so some code has been moved from package
imapserver to package store. the future jmap implementation will benefit from
these changes too. more functionality will probably be moved to the store
package in the future.
the quickstart enables webmail on the internal listener by default (for new
installs). users can enable it on the public listener if they want to. mox
localserve enables it too. to enable webmail on existing installs, add settings
like the following to the listeners in mox.conf, similar to AccountHTTP(S):
WebmailHTTP:
Enabled: true
WebmailHTTPS:
Enabled: true
special thanks to liesbeth, gerben, andrii for early user feedback.
there is plenty still to do, see the list at the top of webmail/webmail.ts.
feedback welcome as always.
2023-08-07 22:57:03 +03:00
|
|
|
package message
|
2023-01-30 16:27:06 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/mjl-/mox/dns"
|
|
|
|
)
|
|
|
|
|
2024-03-13 19:35:53 +03:00
|
|
|
func TestAuthResultsPack(t *testing.T) {
|
2023-01-30 16:27:06 +03:00
|
|
|
dom, err := dns.ParseDomain("møx.example")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("parsing domain: %v", err)
|
|
|
|
}
|
|
|
|
authRes := AuthResults{
|
|
|
|
Hostname: dom.XName(true),
|
|
|
|
Comment: dom.ASCIIExtra(true),
|
|
|
|
Methods: []AuthMethod{
|
2024-03-13 19:35:53 +03:00
|
|
|
{"dkim", "", "pass", "", "", []AuthProp{{"header", "d", dom.XName(true), true, dom.ASCIIExtra(true)}}},
|
2023-01-30 16:27:06 +03:00
|
|
|
},
|
|
|
|
}
|
|
|
|
s := authRes.Header()
|
2023-12-14 17:14:07 +03:00
|
|
|
const exp = "Authentication-Results: (xn--mx-lka.example) møx.example;\r\n\tdkim=pass header.d=møx.example (xn--mx-lka.example)\r\n"
|
2023-01-30 16:27:06 +03:00
|
|
|
if s != exp {
|
|
|
|
t.Fatalf("got %q, expected %q", s, exp)
|
|
|
|
}
|
|
|
|
}
|
2024-03-13 19:35:53 +03:00
|
|
|
|
|
|
|
func TestAuthResultsParse(t *testing.T) {
|
|
|
|
ar, err := ParseAuthResults("(xn--mx-lka.example) møx.example;\r\n\tdkim=pass header.d=møx.example (xn--mx-lka.example)\r\n")
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "møx.example",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "d", Value: "møx.example"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
const localhost = `localhost;
|
|
|
|
auth=pass smtp.mailfrom=mox+qvpVtG6ZQg-vJmN_beaGyQ@localhost
|
|
|
|
`
|
|
|
|
ar, err = ParseAuthResults(localhost)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "localhost",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "auth",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "smtp", Property: "mailfrom", IsAddrLike: true, Value: "mox+qvpVtG6ZQg-vJmN_beaGyQ@localhost"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
const other = `komijn.test.xmox.nl;
|
|
|
|
iprev=pass (without dnssec) policy.iprev=198.2.145.102;
|
|
|
|
dkim=pass (2048 bit rsa, without dnssec) header.d=mandrillapp.com
|
|
|
|
header.s=mte1 header.a=rsa-sha256 header.b="CfNW8cht1/v3";
|
|
|
|
dkim=pass (2048 bit rsa, without dnssec) header.d=letsencrypt.org
|
|
|
|
header.s=mte1 header.a=rsa-sha256 header.b=F9lCi4OC77su
|
|
|
|
header.i=expiry@letsencrypt.org;
|
|
|
|
spf=pass (without dnssec) smtp.mailfrom=delivery.letsencrypt.org;
|
|
|
|
dmarc=pass (without dnssec) header.from=letsencrypt.org
|
|
|
|
`
|
|
|
|
|
|
|
|
ar, err = ParseAuthResults(other)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "komijn.test.xmox.nl",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "iprev",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "policy", Property: "iprev", Value: "198.2.145.102"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "d", Value: "mandrillapp.com"},
|
|
|
|
{Type: "header", Property: "s", Value: "mte1"},
|
|
|
|
{Type: "header", Property: "a", Value: "rsa-sha256"},
|
|
|
|
{Type: "header", Property: "b", Value: "CfNW8cht1/v3"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "d", Value: "letsencrypt.org"},
|
|
|
|
{Type: "header", Property: "s", Value: "mte1"},
|
|
|
|
{Type: "header", Property: "a", Value: "rsa-sha256"},
|
|
|
|
{Type: "header", Property: "b", Value: "F9lCi4OC77su"},
|
|
|
|
{Type: "header", Property: "i", IsAddrLike: true, Value: "expiry@letsencrypt.org"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "spf",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "smtp", Property: "mailfrom", Value: "delivery.letsencrypt.org"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "dmarc",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "from", Value: "letsencrypt.org"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
const google = `mx.google.com;
|
|
|
|
dkim=pass header.i=@test.xmox.nl header.s=2022b header.b="Z9k/yZIA";
|
|
|
|
spf=pass (google.com: domain of mjl@test.xmox.nl designates 2a02:2770::21a:4aff:feba:bde0 as permitted sender) smtp.mailfrom=mjl@test.xmox.nl;
|
|
|
|
dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=test.xmox.nl
|
|
|
|
`
|
|
|
|
|
|
|
|
ar, err = ParseAuthResults(google)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "mx.google.com",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "i", IsAddrLike: true, Value: "@test.xmox.nl"},
|
|
|
|
{Type: "header", Property: "s", Value: "2022b"},
|
|
|
|
{Type: "header", Property: "b", Value: "Z9k/yZIA"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "spf",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "smtp", Property: "mailfrom", IsAddrLike: true, Value: "mjl@test.xmox.nl"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "dmarc",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "from", Value: "test.xmox.nl"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
const yahoo = `atlas220.free.mail.bf1.yahoo.com;
|
|
|
|
dkim=perm_fail header.i=@ueber.net header.s=2023a;
|
|
|
|
dkim=pass header.i=@ueber.net header.s=2023b;
|
|
|
|
spf=pass smtp.mailfrom=ueber.net;
|
|
|
|
dmarc=pass(p=REJECT) header.from=ueber.net;
|
|
|
|
`
|
|
|
|
ar, err = ParseAuthResults(yahoo)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "atlas220.free.mail.bf1.yahoo.com",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "perm_fail",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "i", IsAddrLike: true, Value: "@ueber.net"},
|
|
|
|
{Type: "header", Property: "s", Value: "2023a"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "i", IsAddrLike: true, Value: "@ueber.net"},
|
|
|
|
{Type: "header", Property: "s", Value: "2023b"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "spf",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "smtp", Property: "mailfrom", Value: "ueber.net"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "dmarc",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "from", Value: "ueber.net"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
const proton0 = `mail.protonmail.ch; dkim=pass (Good
|
|
|
|
ed25519-sha256 signature) header.d=ueber.net header.i=mechiel@ueber.net
|
|
|
|
header.a=ed25519-sha256; dkim=pass (Good 2048 bit rsa-sha256 signature)
|
|
|
|
header.d=ueber.net header.i=mechiel@ueber.net header.a=rsa-sha256
|
|
|
|
`
|
|
|
|
ar, err = ParseAuthResults(proton0)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "mail.protonmail.ch",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "d", Value: "ueber.net"},
|
|
|
|
{Type: "header", Property: "i", IsAddrLike: true, Value: "mechiel@ueber.net"},
|
|
|
|
{Type: "header", Property: "a", Value: "ed25519-sha256"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "d", Value: "ueber.net"},
|
|
|
|
{Type: "header", Property: "i", IsAddrLike: true, Value: "mechiel@ueber.net"},
|
|
|
|
{Type: "header", Property: "a", Value: "rsa-sha256"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
const proton1 = `mail.protonmail.ch; dmarc=pass (p=reject dis=none)
|
|
|
|
header.from=ueber.net
|
|
|
|
`
|
|
|
|
ar, err = ParseAuthResults(proton1)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "mail.protonmail.ch",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "dmarc",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "from", Value: "ueber.net"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
const proton2 = `mail.protonmail.ch; spf=pass smtp.mailfrom=ueber.net
|
|
|
|
`
|
|
|
|
ar, err = ParseAuthResults(proton2)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "mail.protonmail.ch",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "spf",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "smtp", Property: "mailfrom", Value: "ueber.net"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
const proton3 = `mail.protonmail.ch; arc=none smtp.remote-ip=84.22.96.237
|
|
|
|
`
|
|
|
|
ar, err = ParseAuthResults(proton3)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "mail.protonmail.ch",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "arc",
|
|
|
|
Result: "none",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "smtp", Property: "remote-ip", Value: "84.22.96.237"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
const proton4 = `mail.protonmail.ch; dkim=permerror (0-bit key) header.d=ueber.net
|
|
|
|
header.i=mechiel@ueber.net header.b="a4SMWyJ7"; dkim=pass (2048-bit key)
|
|
|
|
header.d=ueber.net header.i=mechiel@ueber.net header.b="mQickWQ7"
|
|
|
|
`
|
|
|
|
ar, err = ParseAuthResults(proton4)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "mail.protonmail.ch",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "permerror",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "d", Value: "ueber.net"},
|
|
|
|
{Type: "header", Property: "i", IsAddrLike: true, Value: "mechiel@ueber.net"},
|
|
|
|
{Type: "header", Property: "b", Value: "a4SMWyJ7"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "pass",
|
|
|
|
Props: []AuthProp{
|
|
|
|
{Type: "header", Property: "d", Value: "ueber.net"},
|
|
|
|
{Type: "header", Property: "i", IsAddrLike: true, Value: "mechiel@ueber.net"},
|
|
|
|
{Type: "header", Property: "b", Value: "mQickWQ7"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2024-06-28 11:39:46 +03:00
|
|
|
const dkimReason = `host.example;
|
|
|
|
dkim=none reason="no dkim signatures"
|
|
|
|
`
|
|
|
|
ar, err = ParseAuthResults(dkimReason)
|
|
|
|
tcheck(t, err, "parsing auth results header")
|
|
|
|
tcompare(t, ar, AuthResults{
|
|
|
|
Hostname: "host.example",
|
|
|
|
Methods: []AuthMethod{
|
|
|
|
{
|
|
|
|
Method: "dkim",
|
|
|
|
Result: "none",
|
|
|
|
Reason: "no dkim signatures",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2024-03-13 19:35:53 +03:00
|
|
|
// Outlook adds an invalid line, missing required hostname at the start. And their
|
|
|
|
// dmarc "action=none" is invalid. Nothing to be done.
|
|
|
|
const outlook = `x; spf=pass (sender IP is 84.22.96.237)
|
|
|
|
smtp.mailfrom=ueber.net; dkim=pass (signature was verified)
|
|
|
|
header.d=ueber.net;dmarc=pass action=none header.from=ueber.net;compauth=pass
|
|
|
|
reason=100
|
|
|
|
`
|
|
|
|
_, err = ParseAuthResults(outlook)
|
|
|
|
if err == nil {
|
|
|
|
t.Fatalf("missing error while parsing authresults header from outlook")
|
|
|
|
}
|
|
|
|
}
|