mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-22 10:40:39 +01:00
Refactor error handling in eml parser
Removed redundant error checking in address parsing as netmail.ParseAddressList already performs necessary checks. Added a default error return for unsupported content disposition types to improve robustness.
This commit is contained in:
parent
9f1e1976fe
commit
769783f037
1 changed files with 5 additions and 3 deletions
8
eml.go
8
eml.go
|
@ -218,9 +218,9 @@ func parseEMLHeaders(mailHeader *netmail.Header, msg *Msg) error {
|
|||
for _, addr := range parsedAddrs {
|
||||
addrStrings = append(addrStrings, addr.String())
|
||||
}
|
||||
if err = addrFunc(addrStrings...); err != nil {
|
||||
return fmt.Errorf(`failed to parse %q header: %w`, addrHeader, err)
|
||||
}
|
||||
// We can skip the error checking here since netmail.ParseAddressList already performed the
|
||||
// same address checking that the msg methods do.
|
||||
_ = addrFunc(addrStrings...)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -600,6 +600,8 @@ func parseEMLAttachmentEmbed(contentDisposition []string, multiPart *multipart.P
|
|||
if err := msg.EmbedReader(filename, dataReader); err != nil {
|
||||
return fmt.Errorf("failed to embed multipart body: %w", err)
|
||||
}
|
||||
default:
|
||||
return errors.New("unsupported content disposition type")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue