Go-Mail multiple recipients and attachment

Viewed 18

I am trying to make an email service using go-mail library and made it working. However there are few challenges that i am unable to solve

I have the struct for form data-

type SendMailBody struct {
    EmailTo []string `form:"sendTo"`
    Subject string   `form:"subject"`
    Body    string   `form:"body"`
}

The form data that i am sending to the API is

subject: Notification
sendTo:["abc@gmail.com", "xyz@gmail.com"]
body:You have been notified

Challenges-

  1. If I pass a single email in "sendTO", It is working fine. But after passing the slice of emails, it is unable to send emails to the recepients. How can i make it work?

  2. If I pass the attachment through Form data, how can I attach it with the mail. In documentation, it is mentioned that we can do it like that "m.Attach("/tmp/image.jpg")" . But how should i do it if i pass the attachment via form data in API

Please guide me through that.

0 Answers
Related