Commit 8b8e57b7 authored by Henry's avatar Henry Committed by Ian Lance Taylor

net/smtp: added Noop to Client

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: 's avatarIan Lance Taylor <iant@golang.org>
parent eed308de
......@@ -398,6 +398,16 @@ func (c *Client) Reset() error {
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 {
......
......@@ -478,6 +478,8 @@ func TestHello(t *testing.T) {
t.Errorf("Want error, got none")
}
}
case 9:
err = c.Noop()
default:
t.Fatalf("Unhandled command")
}
......@@ -510,6 +512,7 @@ var helloServer = []string{
"250 Reset ok\n",
"221 Goodbye\n",
"250 Sender ok\n",
"250 ok\n",
}
var baseHelloClient = `EHLO customhost
......@@ -526,6 +529,7 @@ var helloClient = []string{
"RSET\n",
"QUIT\n",
"VRFY test@example.com\n",
"NOOP\n",
}
func TestSendMail(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment