feat(mail): derive bare envelope sender from display-name From
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -100,6 +100,36 @@ func TestRecipientsCombinesAllFields(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnvelopeFromStripsDisplayName(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"Steve Cliff <me@stevecliff.com>": "me@stevecliff.com",
|
||||
"me@stevecliff.com": "me@stevecliff.com",
|
||||
"<me@stevecliff.com>": "me@stevecliff.com",
|
||||
"not a valid address": "not a valid address", // unparseable ⇒ passthrough
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := envelopeFrom(in); got != want {
|
||||
t.Fatalf("envelopeFrom(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildMIMEKeepsDisplayNameInHeader(t *testing.T) {
|
||||
raw, err := BuildMIME(OutgoingMessage{
|
||||
From: "Steve Cliff <me@stevecliff.com>",
|
||||
To: []string{"you@example.com"},
|
||||
Subject: "hi",
|
||||
BodyText: "body",
|
||||
Date: time.Date(2026, 6, 23, 12, 0, 0, 0, time.UTC),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("BuildMIME: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(raw), "Steve Cliff") {
|
||||
t.Fatalf("From header lost display name:\n%s", raw)
|
||||
}
|
||||
}
|
||||
|
||||
func TestReadHeaderParsesReferences(t *testing.T) {
|
||||
raw := "From: a@x.com\r\n" +
|
||||
"To: b@x.com\r\n" +
|
||||
|
||||
Reference in New Issue
Block a user