go-gomail / gomail

The best way to send emails in Go.
MIT License
4.3k stars 570 forks source link

write: broken pipe #121

Open arundudeemmt opened 5 years ago

arundudeemmt commented 5 years ago

when using gomail it works fine in first go but after hour which is like default timeout of smtp servers, if email is sent then a following error is thrown : gomail: could not send email 1: write tcp XXXXXXXX:8807->YYYYYYYYYYY:25: write: broken pipe

Looked at code but seems we are checking io.eof error only and we do dial again but there in other cases error is not handled .

func (c smtpSender) Send(from string, to []string, msg io.WriterTo) error { if err := c.Mail(from); err != nil { if err == io.EOF { // This is probably due to a timeout, so reconnect and try again. sc, derr := c.d.Dial() if derr == nil { if s, ok := sc.(smtpSender); ok { c = s return c.Send(from, to, msg) } } } return err } IMO we need to do sc, derr := c.d.Dial() in other error conditions too .