Skip to content

Commit

Permalink
Ignore empty address parsing
Browse files Browse the repository at this point in the history
Fix #3
  • Loading branch information
xhit committed May 26, 2020
1 parent 9f4ee37 commit 5806fb9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions email.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,18 @@ func (email *Email) AddAddresses(header string, addresses ...string) *Email {

// check to see if the addresses are valid
for i := range addresses {
address, err := mail.ParseAddress(addresses[i])
if err != nil {
email.Error = errors.New("Mail Error: " + err.Error() + "; Header: [" + header + "] Address: [" + addresses[i] + "]")
return email
var address = new(mail.Address)
var err error

// ignore parse the address if empty
if len(addresses[i]) > 0 {
address, err = mail.ParseAddress(addresses[i])
if err != nil {
email.Error = errors.New("Mail Error: " + err.Error() + "; Header: [" + header + "] Address: [" + addresses[i] + "]")
return email
}
} else {
continue
}

// check for more than one address
Expand Down

0 comments on commit 5806fb9

Please sign in to comment.