本文整理汇总了Golang中net/textproto.Conn.ReadDotBytes方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.ReadDotBytes方法的具体用法?Golang Conn.ReadDotBytes怎么用?Golang Conn.ReadDotBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net/textproto.Conn
的用法示例。
在下文中一共展示了Conn.ReadDotBytes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: converse
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)
}
}
}