Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postfix bounces address aren't RFC compliant #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions eazye.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func GenerateSince(info MailboxInfo, since time.Time, markAsRead, delete bool) (
type Email struct {
Message *mail.Message

From *mail.Address `json:"from"`
From string `json:"from"`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making this a breaking change, could we expose this by adding a new FromRaw string?

To []*mail.Address `json:"to"`
InternalDate time.Time `json:"internal_date"`
Precedence string `json:"precedence"`
Expand Down Expand Up @@ -503,9 +503,18 @@ func newEmail(msgFields imap.FieldMap) (Email, error) {
return email, fmt.Errorf("unable to read header: %s", err)
}

from, err := mail.ParseAddress(msg.Header.Get("From"))
if err != nil {
return email, fmt.Errorf("unable to parse from address: %s", err)
rawFrom := msg.Header.Get("From")
rawFromSl := strings.Fields(rawFrom)
from := ""
for _, rF := range rawFromSl {
f, err := mail.ParseAddress(rF)
if err != nil {
continue
}
from = f.Address
}
if len(from) == 0 {
from = rawFrom
}

to, err := mail.ParseAddressList(msg.Header.Get("To"))
Expand Down