Skip to content

Commit

Permalink
Merge pull request #2 from voedoo/master
Browse files Browse the repository at this point in the history
Обновление для получения писем с пустым To и Cc.
  • Loading branch information
dev-nodasoft authored Jul 3, 2019
2 parents 1efc794 + 9f4292f commit e15de2b
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions eazye.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,22 @@ func NewEmail(msgFields imap.FieldMap) (Email, error) {
return email, fmt.Errorf("unable to parse from address: %s", err)
}

to, err := mail.ParseAddressList(msg.Header.Get("To"))
if err != nil {
return email, fmt.Errorf("unable to parse to address: %s", err)
var (
to []*mail.Address
cc []*mail.Address
)
if toHeader := msg.Header.Get("To"); toHeader != "" {
to, err = mail.ParseAddressList(toHeader)
if err != nil {
return email, fmt.Errorf("unable to parse to address: %s", err)
}
}

cc, err := mail.ParseAddressList(msg.Header.Get("Cc"))
if err != nil {
return email, fmt.Errorf("unable to parse cc adress: %s", err)
if ccHeader := msg.Header.Get("Cc"); ccHeader != "" {
cc, err = mail.ParseAddressList(ccHeader)
if err != nil {
return email, fmt.Errorf("unable to parse cc address: %s", err)
}
}

email = Email{
Expand Down

0 comments on commit e15de2b

Please sign in to comment.