Use DialSender returned by gomail.Dial.
You don't need the parsed message for it, just the from and to addresses, 
and write the contents of the .eml file into the WriterTo as is.

sandip bait a következőt írta (2020. szeptember 14., hétfő, 1:06:50 UTC+2):

> I am using Standard *gomail <https://github.com/go-gomail/gomail>* package 
> for sending mails in Golang. The mail generation part is happing from some 
> other component which i am storing it in a particular location (i.e 
> */path/sample.eml* file). And hence , i have pre-cooked mail body in .EML 
> file which i just want process as a new mail. I am able to put/parse the 
> .EML content by using the *parsemail 
> <https://github.com/DusanKasan/parsemail>* package of *DusanKasan*. There 
> are so many custom headers which i have already set in raw *sample.eml* file 
> content which i want to send. It will be really helpful if i get an example 
> code saying just pass *.eml* file as a input so that mail body will 
> generate/render based on *.eml* file content.
>
> You can fine sample EML content string on *.EML 
> <https://play.golang.org/p/mlDANqTLmj9>*Here is my basic mail sending 
> code using *gomail <https://github.com/go-gomail/gomail>* 
>
> package.m := gomail.NewMessage() 
> m.SetHeader("From", "[email protected]") 
> m.SetHeader("To", "[email protected]", "[email protected]") 
> m.SetAddressHeader("Cc", "[email protected]", "Dan") 
> m.SetHeader("Subject", "Hello!") m.SetBody("text/html", "Hello <b>Bob</b> 
> and <i>Cora</i>!") m.Attach("/home/Alex/lolcat.jpg") 
>  d := gomail.NewDialer("smtp.example.com", 587, "user", "123456") // Send 
> the email to Bob, Cora and Dan.
> if err := d.DialAndSend(m); err != nil { panic(err) }
>
> Here is my eml parsing code using parsemail *parsemail 
> <https://github.com/DusanKasan/parsemail>* package
>
> var reader io.Reader // this reads an email message 
> email, err := parsemail.Parse(reader) // returns Email struct and error if 
> err != nil { // handle error } fmt.Println(email.Subject) 
> fmt.Println(email.From) 
> fmt.Println(email.To) 
> fmt.Println(email.HTMLBody) 
>
> Thanks & Regards,
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4f235f30-c515-4896-9162-531917b717f8n%40googlegroups.com.

Reply via email to