Whether there is a method to set timeout on dial and on send ? Without setting timeout on sending, it spent 5 minutes to send an email. Badly, it will hang up, then cause bug on production.
在 2017年8月25日星期五 UTC+8下午12:17:12,Antonio Sun写道: > > You should break that 40s up and see how long is spent on dial, and how > long is spent on send. > > On Thu, Aug 24, 2017 at 9:41 PM, <yhj7...@163.com <javascript:>> wrote: > >> Thank you very much for your reply. However, in my code, it spent 40s to >> send email. >> >> Here is the code: >> >> now := time.Now() >> msg := gomail.NewMessage() >> //the element of msg is abridged >> dial := gomail.Dialer{Host: "127.0.0.1", Port: 25} >> dial.TLSConfig = &tls.Config{InsecureSkipVerify: true} >> if err := dial.DialAndSend(msg); err != nil { >> log.Fatal("failed to send email", err) >> } else { >> timeSpent := fmt.Sprintf("%.3f s", time.Since(now).Seconds()) >> fmt.Println("time to spend in sending email", timeSpent ) >> } >> >> 在 2017年8月25日星期五 UTC+8上午1:53:48,Tamás Gulácsi写道: >> >>> It uses a constant 10s timeout for dial. What should time out? >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "golang-nuts" group. >> To unsubscribe from this topic, visit >> https://groups.google.com/d/topic/golang-nuts/jMxZHzvvEVg/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> golang-nuts...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.