webmail: fix for ignoring error about sending to invalid address

before, an error about an invalid address was not used, causing a delivery
attempt to an empty address (empty localpart/domain). delivery to that address
would fail, but we should've prevented that message from being queued at all.

additionally, an error in adding the message to the queue was ignored too.
This commit is contained in:
Mechiel Lukkien
2024-03-09 09:51:24 +01:00
parent c57aeac7f0
commit 63cef8e3a5
2 changed files with 13 additions and 4 deletions

View File

@ -253,6 +253,14 @@ func Add(ctx context.Context, log mlog.Log, senderAccount string, msgFile *os.Fi
if qm.ID != 0 {
return fmt.Errorf("id of queued messages must be 0")
}
if qm.RecipientDomainStr == "" {
return fmt.Errorf("recipient domain cannot be empty")
}
// Sanity check, internal consistency.
rcptDom := formatIPDomain(qm.RecipientDomain)
if qm.RecipientDomainStr != rcptDom {
return fmt.Errorf("mismatch between recipient domain and string form of domain")
}
}
if Localserve {