Re: [go-nuts] Re: [ANN] Gomail v2: sending emails faster

2017-08-28 Thread Antonio Sun
On Sun, Aug 27, 2017 at 10:31 PM,  wrote:

>
> Without setting timeout on sending, it spent 5 minutes to send an email.
> Badly, it will hang up, then cause bug on production.
>

That means the mail server is busy. Setting shorter timeout will
stress mail server even more and make things worse for everyone.

The proper way is wait, and retry (dialing), with each retry waiting twice
as long as before. So even if the remote mail server is down for a few
hours, you email can still go through eventually.

-- 
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.


Re: [go-nuts] Re: [ANN] Gomail v2: sending emails faster

2017-08-24 Thread 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,  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 = {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+unsubscr...@googlegroups.com.
> 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.