Would you be open to providing a way to convert email struct into raw format? #60
sarthak-kothari
started this conversation in
Ideas
Replies: 1 comment
-
I think you could use the underlying net/mail structures for manipulating header fields. Eg: package main
import (
"fmt"
"log"
"net/mail"
"os"
"github.com/mnako/letters"
)
func main() {
file := "testfiles/topdir/dir1/email2.eml"
e, err := os.Open(file)
if err != nil {
log.Fatalf("open err %v", err)
}
message, err := letters.ParseEmail(e)
// fmt.Printf("%#v\n", message.Headers) // letters.Headers
fmt.Printf("%v\n", message.Headers.From)
newFrom := &mail.Address{
Name: "Example Name",
Address: "address@example.com",
}
message.Headers.From = []*mail.Address{newFrom}
fmt.Printf("%v\n", message.Headers.From)
} Converting the
So you could just use those to make the string output you want. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Basically you take a raw formatted io.Reader as input and we get the
email
struct.If we wanted to manipulate some fields and then convert the struct to a simple string, would it be possible to support that?
great work btw!
Beta Was this translation helpful? Give feedback.
All reactions