diff options
| author | Shulhan <ms@kilabit.info> | 2019-01-15 22:54:53 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2019-01-15 22:54:53 +0700 |
| commit | 05b758f6283c8307c99ea82a2a5f4291f3e75a41 (patch) | |
| tree | 4c6c93c1a73a0df587a9a9173fe70c278090a32a | |
| parent | 6aef23da058f979d4a43565e11974e6f85ebfbd6 (diff) | |
| download | pakakeh.go-05b758f6283c8307c99ea82a2a5f4291f3e75a41.tar.xz | |
lib/smtp: export the field ServerInfo in Client struct
The non nil ServerInfo indicate that client has been called EHLO or HELO
before, which required for client to check whether server support AUTH
extension or not.
| -rw-r--r-- | lib/smtp/client.go | 17 | ||||
| -rw-r--r-- | lib/smtp/client_test.go | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/smtp/client.go b/lib/smtp/client.go index a3bb520a..694ba35c 100644 --- a/lib/smtp/client.go +++ b/lib/smtp/client.go @@ -22,11 +22,14 @@ import ( // Client for SMTP. // type Client struct { - data []byte - buf bytes.Buffer - raddr *net.TCPAddr - conn net.Conn - serverInfo *ServerInfo + // ServerInfo contains the server information, from the response of + // EHLO command. + ServerInfo *ServerInfo + + data []byte + buf bytes.Buffer + raddr *net.TCPAddr + conn net.Conn } // @@ -128,7 +131,7 @@ func (cl *Client) Ehlo(domAddr string) (res *Response, err error) { } if res.Code == StatusOK { - cl.serverInfo = NewServerInfo(res) + cl.ServerInfo = NewServerInfo(res) return res, nil } @@ -197,7 +200,7 @@ func (cl *Client) MailTx(mail *MailTx) (res *Response, err error) { if len(mail.Recipients) == 0 { return nil, errors.New("SendMailTx: empty mail 'Recipients' parameter") } - if cl.serverInfo == nil { + if cl.ServerInfo == nil { res, err = cl.Ehlo("localhost") if err != nil { return nil, err diff --git a/lib/smtp/client_test.go b/lib/smtp/client_test.go index 1c04bfce..43e03f5c 100644 --- a/lib/smtp/client_test.go +++ b/lib/smtp/client_test.go @@ -64,7 +64,7 @@ func TestEhlo(t *testing.T) { test.Assert(t, "Ehlo", c.exp, got, true) test.Assert(t, "ServerInfo", c.expServerInfo, - testClient.serverInfo, true) + testClient.ServerInfo, true) } } |
