This adds a Noop() function to the net/stmp client.
It allows for testing if a connaction is still healthy.
Fixes #22321
Change-Id: I023b613b1536ea21274cc36d41f5720c9bbdecbc
Reviewed-on: https://go-review.googlesource.com/71650
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
return err
}
+// Noop sends the NOOP command to the server. It does nothing but check
+// that the connaction to the server is okay.
+func (c *Client) Noop() error {
+ if err := c.hello(); err != nil {
+ return err
+ }
+ _, _, err := c.cmd(250, "NOOP")
+ return err
+}
+
// Quit sends the QUIT command and closes the connection to the server.
func (c *Client) Quit() error {
if err := c.hello(); err != nil {
t.Errorf("Want error, got none")
}
}
+ case 9:
+ err = c.Noop()
default:
t.Fatalf("Unhandled command")
}
"250 Reset ok\n",
"221 Goodbye\n",
"250 Sender ok\n",
+ "250 ok\n",
}
var baseHelloClient = `EHLO customhost
"RSET\n",
"QUIT\n",
"VRFY test@example.com\n",
+ "NOOP\n",
}
func TestSendMail(t *testing.T) {