Skip to content

Commit

Permalink
Fix Conn.Hostname being empty when NewSession is called
Browse files Browse the repository at this point in the history
  • Loading branch information
foxcpp authored and emersion committed Jan 21, 2024
1 parent da7af50 commit df9dfa9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,14 @@ func (c *Conn) handleGreet(enhanced bool, arg string) {
c.writeResponse(501, EnhancedCode{5, 5, 2}, "Domain/address argument required for HELO")
return
}
// c.helo is populated before NewSession so
// NewSession can access it via Conn.Hostname.
c.helo = domain

sess, err := c.server.Backend.NewSession(c)
if err != nil {
c.helo = ""

if smtpErr, ok := err.(*SMTPError); ok {
c.writeResponse(smtpErr.Code, smtpErr.EnhancedCode, smtpErr.Message)
return
Expand All @@ -238,7 +243,6 @@ func (c *Conn) handleGreet(enhanced bool, arg string) {
return
}

c.helo = domain
c.setSession(sess)

if !enhanced {
Expand Down

0 comments on commit df9dfa9

Please sign in to comment.