Multiple files attached and sending an email by using Golang

Save the .xlxs file over the disk then attach it using path. It will work perfectly.

Here is a sample code and it's working fine :

func main() {
    m := gomail.NewMessage()
    m.SetHeader("From", "[email protected]")
    m.SetHeader("To", "[email protected]")
    m.SetAddressHeader("Cc", "[email protected]", "Vande")
    m.SetHeader("Subject", "Hello! New Mail")
    m.SetBody("text/html", "Hello <b>Bob</b> and <i>Cora</i>!")
    m.Attach("attach.xlsx")

    d := gomail.NewDialer("smtp.gmail.com", 2525, "user", "password")
    d.TLSConfig = &tls.Config{InsecureSkipVerify: true}

    if err := d.DialAndSend(m); err != nil {
        fmt.Print(err)
        panic(err)

    } else {
        fmt.Print("sent")
    }

}

Project Architecture :

send_mail    //project name
  attach.xlxs  //file
  main.go
  go.mod