log all smtp connection errors

This commit is contained in:
Aine
2023-02-11 21:20:41 +02:00
parent 6d55ee40ed
commit 7d0d8cd2e6
5 changed files with 14 additions and 10 deletions

View File

@@ -93,10 +93,13 @@ func (m *mailServer) AnonymousLogin(state *smtp.ConnectionState) (smtp.Session,
func (m *mailServer) SendEmail(from, to, data string) error {
m.log.Debug("Sending email from %s to %s", from, to)
conn, err := trysmtp.Connect(from, to)
if err != nil {
if conn == nil {
m.log.Error("cannot connect to SMTP server of %s: %v", to, err)
return err
}
if err != nil {
m.log.Warn("connection to the SMTP server of %s returned the following non-fatal error(-s): %v", err)
}
defer conn.Close()
var w io.WriteCloser