func converse(c *textproto.Conn, verifyOnly bool) { write(c, "220 At your service") var msg Msg for { s, err := read(c) if err == io.EOF { return } if verifyOnly { log.Println("Incoming:", s) } cmd := strings.ToUpper(s[:4]) switch cmd { case "EHLO": write(c, "250-8BITMIME") fallthrough case "HELO": write(c, "250 I need orders") case "MAIL": msg.From = addrRegex.FindStringSubmatch(s)[1] write(c, "250 In your name") case "RCPT": addr := addrRegex.FindStringSubmatch(s)[1] msg.To = append(msg.To, addr) write(c, "250 Defending your honour") case "DATA": if verifyOnly { write(c, "502 Verification service only") return } write(c, "354 Give me a quest!") data, err := c.ReadDotBytes() if err != nil { panic(err) } msg.Data = data defaultHandle(&msg) write(c, "250 We move") case "RSET": write(c, "250 OK") case "QUIT": write(c, "221 For the king") default: log.Println("Unknown command:", s) } } }