Skip to content

Commit df9dfa9

Browse files
foxcppemersion
authored andcommitted
Fix Conn.Hostname being empty when NewSession is called
1 parent da7af50 commit df9dfa9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

conn.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,14 @@ func (c *Conn) handleGreet(enhanced bool, arg string) {
227227
c.writeResponse(501, EnhancedCode{5, 5, 2}, "Domain/address argument required for HELO")
228228
return
229229
}
230+
// c.helo is populated before NewSession so
231+
// NewSession can access it via Conn.Hostname.
232+
c.helo = domain
230233

231234
sess, err := c.server.Backend.NewSession(c)
232235
if err != nil {
236+
c.helo = ""
237+
233238
if smtpErr, ok := err.(*SMTPError); ok {
234239
c.writeResponse(smtpErr.Code, smtpErr.EnhancedCode, smtpErr.Message)
235240
return
@@ -238,7 +243,6 @@ func (c *Conn) handleGreet(enhanced bool, arg string) {
238243
return
239244
}
240245

241-
c.helo = domain
242246
c.setSession(sess)
243247

244248
if !enhanced {

0 commit comments

Comments
 (0)