veqryn/go-email

mail: no address error when CC and BCC not set

stephenhyde opened this issue · 2 comments

Due to Bcc and Cc being string maps, when you do a get on it it will return a string byte slice of one item with empty string. This causes the parse message to error on line 29 of email/sender.go. Returning "mail:no address".

Fix: Do a get on key first and if empty string return empty byte slice.

i.e

// Cc ...
func (h Header) Cc() []string {
cc := h.Get("Cc")
if cc == "" {
return []string{}
}
return strings.Split(cc, ", ")
}

This was merged in. Closing.