Here is th code:
func sendMail() error{
m := gomail.NewMessage()
m.SetHeader("From", From)
m.SetHeader("To", "bacobas.f@gmail.com")
m.SetHeader("Subject", "Hello!")
m.SetBody("text/html", "Hello <b>Bob</b> and <i>Cora</i>!")
m.Attach("./video.mp4")
//m.Attach("./Autorizzazione.pdf")
d := gomail.NewDialer(SmtpHost, SmtpPort, From, PswFrom)
// Send the email to Bob, Cora and Dan.
if err := d.DialAndSend(m); err != nil {
return err
}
return nil}
If attach "Autorizzazione.pdf" it works. Also if I don't attach anthing. But if i try to attach this .mp4 file the output is Error: gomail: could not send email 1: write tcp <my LAN wi-fi ip address>:54988->142.250.147.109:587: wsasend: An existing connection was forcibly closed by the remote host.
This function is called inside an HandleFunc()
in my little http server and the return of this function is basically ""printed"" as a return of that api
Can someone help me please?