We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
`X-MS-Exchange-Organization-Processed-By-Gcc-Journaling: Journal Agent Content-Type: multipart/mixed; boundary="a5093c80-52fc-4ad9-bca7-3906fe47922d"
--a5093c80-52fc-4ad9-bca7-3906fe47922d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable`
email, err := letters.ParseEmail(r) if err != nil { log.Fatal(err) }
letters.parsers.parsePart: cannot parse Content-Disposition: letters.parsers.parseContentDisposition: unknown Content-Disposition "attachfile"
Normaly letters works fine. It seems a special structure of this emails I have some eml-files to produce the error. (Only via private mail)
(with standard go libraries isit possible to extract attachments without errors)
`package main
import ( "encoding/base64" "fmt" "io" "mime" "mime/multipart" "net/mail" "os" "strings" )
func main() {
emlFile, err := os.Open(`test.eml`) if err != nil { panic(err) } defer emlFile.Close() msg, err := mail.ReadMessage(emlFile) if err != nil { panic(err) } // Get MIME-Typ mediaType, params, err := mime.ParseMediaType(msg.Header.Get("Content-Type")) if err != nil { panic(err) } // multipart-message? if strings.HasPrefix(mediaType, "multipart/") { mr := multipart.NewReader(msg.Body, params["boundary"]) for { p, err := mr.NextPart() if err == io.EOF { break } if err != nil { panic(err) } if cd := p.Header.Get("Content-Disposition"); strings.Contains(cd, "attachFile") { filename := p.FileName() // Content-Transfer-Encoding-Header var reader io.Reader switch p.Header.Get("Content-Transfer-Encoding") { case "base64": reader = base64.NewDecoder(base64.StdEncoding, p) default: reader = p } data, err := io.ReadAll(reader) if err != nil { panic(err) } // save attachment to file err = os.WriteFile(filename, data, 0644) if err != nil { panic(err) } fmt.Printf("attachment %s saved\n", filename) } } }
} `
The text was updated successfully, but these errors were encountered:
@bsc-computer Could you share the Content-Disposition header or a bit more elaborate sample eml file with which we can reproduce this?
Content-Disposition
Sorry, something went wrong.
No branches or pull requests
Part of eml-file
`X-MS-Exchange-Organization-Processed-By-Gcc-Journaling: Journal Agent
Content-Type: multipart/mixed;
boundary="a5093c80-52fc-4ad9-bca7-3906fe47922d"
--a5093c80-52fc-4ad9-bca7-3906fe47922d
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable`
code
email, err := letters.ParseEmail(r) if err != nil { log.Fatal(err) }
output
letters.parsers.parsePart: cannot parse Content-Disposition: letters.parsers.parseContentDisposition: unknown Content-Disposition "attachfile"
Normaly letters works fine.
It seems a special structure of this emails
I have some eml-files to produce the error. (Only via private mail)
workaround
(with standard go libraries isit possible to extract attachments without errors)
`package main
import (
"encoding/base64"
"fmt"
"io"
"mime"
"mime/multipart"
"net/mail"
"os"
"strings"
)
func main() {
}
`
The text was updated successfully, but these errors were encountered: