Skip to content

Commit

Permalink
Refactor RequestMDNAddTo
Browse files Browse the repository at this point in the history
Simplify the address handling for the "Disposition-Notification-To" header in msg.go. The code now directly reassigns the previously fetched addresses and ensures appending the new address effectively. This improves code readability and correctness in updating the header.
  • Loading branch information
wneessen committed Oct 26, 2024
1 parent 4f97cd8 commit 4fe9022
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -1237,11 +1237,11 @@ func (m *Msg) RequestMDNAddTo(rcpt string) error {
return fmt.Errorf(errParseMailAddr, rcpt, err)
}
var addresses []string
addresses = append(addresses, m.genHeader[HeaderDispositionNotificationTo]...)
addresses = append(addresses, address.String())
if _, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
m.genHeader[HeaderDispositionNotificationTo] = addresses
if current, ok := m.genHeader[HeaderDispositionNotificationTo]; ok {
addresses = current
}
addresses = append(addresses, address.String())
m.genHeader[HeaderDispositionNotificationTo] = addresses
return nil
}

Expand Down

0 comments on commit 4fe9022

Please sign in to comment.