add deferred Close to smtp writer
This commit is contained in:
parent
6ab65d88e5
commit
599d23e080
|
@ -120,17 +120,13 @@ func (m *SendMailRequest) Execute() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed issuing DATA command (%s)", err)
|
return fmt.Errorf("failed issuing DATA command (%s)", err)
|
||||||
}
|
}
|
||||||
|
defer smtpWriter.Close()
|
||||||
|
|
||||||
_, err = smtpWriter.Write([]byte(msg))
|
_, err = smtpWriter.Write([]byte(msg))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed sending mail content (%s)", err)
|
return fmt.Errorf("failed sending mail content (%s)", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = smtpWriter.Close()
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed close smtp client (%s)", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue