From 4fe90228158268fe32b21057dec61bf3b935379c Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 26 Oct 2024 22:13:37 +0200 Subject: [PATCH] Refactor RequestMDNAddTo 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. --- msg.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/msg.go b/msg.go index 8ce7a91..c770973 100644 --- a/msg.go +++ b/msg.go @@ -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 }