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

Some emails retrieved by header.Get may not be transcoded #356

Open
ltybenet opened this issue Nov 6, 2024 · 2 comments
Open

Some emails retrieved by header.Get may not be transcoded #356

ltybenet opened this issue Nov 6, 2024 · 2 comments

Comments

@ltybenet
Copy link

ltybenet commented Nov 6, 2024

Secondary transcoding using DecodeRFC2047 is successful

subject := header.Get("Subject")
if strings.Contains(subject, "=?") {
    subject = enmime.DecodeRFC2047(subject)
}
@jhillyerd
Copy link
Owner

I'd need more info to be able to investigate this. What is header in the snippet you posted? Do you have a sample subject line?

@ltybenet
Copy link
Author

ltybenet commented Nov 6, 2024

The header of the file "1.eml" is the following characters
// Subject: =?iso-2022-jp?B?MRskQjdvJE49ODJZJE5ESTJDJEgkSiRqJF4kOSEjGyhC?=

This is part of my code

f, err := os.Open("1.eml")
if err != nil {
    a.log.Error("Open file error", f.Name(), err)
}
defer f.Close()
reader := bufio.NewReader(f)
var p enmime.ErrorCollector
header, err := enmime.ReadHeader(reader, p)
if err != nil {
    a.log.Error(fmt.Sprintf("Error, %s %s", f.Name(), err.Error()))
}

subject := header.Get("Subject")
if strings.Contains(subject, "=?") {
    subject = enmime.DecodeRFC2047(subject)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants