fix: close smtp client connection
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
44e9c0ad5d
commit
953497a1fe
@ -165,6 +165,14 @@ func (p *Plugin) sendMail(recipient string, r io.Reader) error {
|
|||||||
return fmt.Errorf("failed to copy input from passed reader to smtp writer: %w", err)
|
return fmt.Errorf("failed to copy input from passed reader to smtp writer: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// close smtpClient before defer to avoid returning an error of
|
||||||
|
// smtpClient.Quit() like the following example:
|
||||||
|
// Error: failed to execute mail plugin: failed to send mail: failed to send quit command: 250 2.0.0 Ok: queued as C7F009B4ED
|
||||||
|
err = wc.Close()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to close smtp client connection: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
err = smtpClient.Quit()
|
err = smtpClient.Quit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to send quit command: %w", err)
|
return fmt.Errorf("failed to send quit command: %w", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user