Guard against empty From header in IMAP message fetch

Bounce messages and MAILER-DAEMON notices can have no From address,
causing a panic on the bare [0] index access.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Harry Culpan 2026-06-30 18:29:05 -04:00
parent 2d6436dca6
commit c509641f59

View file

@ -74,6 +74,9 @@ func fetchEmails(imapClient *client.Client) ([]Email, error) {
}()
for msg := range messages {
if len(msg.Envelope.From) == 0 {
continue
}
toAddress := concatAddresses(msg.Envelope.To)
fromAddress := msg.Envelope.From[0].Address()
r := msg.GetBody(section)