File tree 1 file changed +8
-8
lines changed
1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -29,8 +29,9 @@ type Client struct {
29
29
lmtp bool
30
30
ext map [string ]string // supported extensions
31
31
localName string // the name to use in HELO/EHLO/LHLO
32
- didHello bool // whether we've said HELO/EHLO/LHLO
33
32
didGreet bool // whether we've received greeting from server
33
+ greetError error // the error from the greeting
34
+ didHello bool // whether we've said HELO/EHLO/LHLO
34
35
helloError error // the error from the hello
35
36
rcpts []string // recipients accumulated for the current session
36
37
@@ -181,21 +182,21 @@ func (c *Client) Close() error {
181
182
182
183
func (c * Client ) greet () error {
183
184
if c .didGreet {
184
- return nil
185
+ return c . greetError
185
186
}
186
187
187
188
// Initial greeting timeout. RFC 5321 recommends 5 minutes.
188
189
c .conn .SetDeadline (time .Now ().Add (c .CommandTimeout ))
189
190
defer c .conn .SetDeadline (time.Time {})
190
191
192
+ c .didGreet = true
191
193
_ , _ , err := c .readResponse (220 )
192
194
if err != nil {
195
+ c .greetError = err
193
196
c .text .Close ()
194
- return err
195
197
}
196
198
197
- c .didGreet = true
198
- return nil
199
+ return c .greetError
199
200
}
200
201
201
202
// hello runs a hello exchange if needed.
@@ -204,12 +205,11 @@ func (c *Client) hello() error {
204
205
return c .helloError
205
206
}
206
207
207
- c .didHello = true
208
208
if err := c .greet (); err != nil {
209
- c .helloError = err
210
- return c .helloError
209
+ return err
211
210
}
212
211
212
+ c .didHello = true
213
213
if err := c .ehlo (); err != nil {
214
214
var smtpError * SMTPError
215
215
if errors .As (err , & smtpError ) && (smtpError .Code == 500 || smtpError .Code == 502 ) {
You can’t perform that action at this time.
0 commit comments