From 085e61afb5fd96e22571f6ef3fa90a0a0581b783 Mon Sep 17 00:00:00 2001 From: Drew Smirnoff Date: Sun, 3 May 2026 01:10:14 +0400 Subject: [PATCH] fix: reply with To address for catchall (#1217) ## What? Adds an automatic override for the `From` field in reply composer for catch-all accounts ## Why? Requested by @EmilyxFox on [Discord](https://discord.gg/jVnYTeSPV8). Signed-off-by: drew --- main.go | 19 +++++++++++++++++++ tui/composer.go | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/main.go b/main.go index 21650a2d8acbf75eabab6ce22b7bad1fd9e79796..4b9fe871159323ae160d76fb8bb26ad22301c11a 100644 --- a/main.go +++ b/main.go @@ -12,6 +12,7 @@ import ( "fmt" "io" "log" + "net/mail" "net/url" "os" "os/exec" @@ -1379,6 +1380,24 @@ func (m *mainModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { accountID = m.config.GetFirstAccount().ID } composer = tui.NewComposerWithAccounts(m.config.Accounts, accountID, to, subject, "", hideTips) + // For catch-all accounts, pre-fill From with the specific address the email was delivered to. + if len(msg.Email.To) > 0 { + for i := range m.config.Accounts { + if m.config.Accounts[i].ID == accountID && m.config.Accounts[i].CatchAll { + acc := &m.config.Accounts[i] + deliveryAddr := msg.Email.To[0] + if addr, err := mail.ParseAddress(deliveryAddr); err == nil { + deliveryAddr = addr.Address + } + fromVal := deliveryAddr + if acc.Name != "" { + fromVal = fmt.Sprintf("%s <%s>", acc.Name, deliveryAddr) + } + composer.SetFromOverride(fromVal) + break + } + } + } } else { composer = tui.NewComposer("", to, subject, "", hideTips) } diff --git a/tui/composer.go b/tui/composer.go index 4d07466e4a177c4faa25dd5c3de31b82ba3488bb..285c9eaf5bad2be44100bdb2d2a768b38bebed9e 100644 --- a/tui/composer.go +++ b/tui/composer.go @@ -200,6 +200,11 @@ func (m *Composer) ResetConfirmation() { m.confirmingExit = false } +// SetFromOverride pre-fills the editable From field (used for catch-all replies). +func (m *Composer) SetFromOverride(addr string) { + m.fromInput.SetValue(addr) +} + func (m *Composer) Init() tea.Cmd { return textinput.Blink }