Add the first test for SMTP connections, based on the exchange in RFC 5321.
[mailpopbox.git] / smtp / server.go
1 package smtp
2
3 import (
4 "crypto/tls"
5 "net"
6 "net/mail"
7 )
8
9 type ReplyLine struct {
10 Code int
11 Message string
12 }
13
14 var (
15 ReplyOK = ReplyLine{250, "OK"}
16 ReplyBadSyntax = ReplyLine{501, "syntax error"}
17 ReplyBadSequence = ReplyLine{503, "bad sequence of commands"}
18 )
19
20 type Envelope struct {
21 RemoteAddr net.Addr
22 EHLO string
23 MailFrom mail.Address
24 RcptTo []mail.Address
25 Data []byte
26 }
27
28 type Server interface {
29 Name() string
30 TLSConfig() *tls.Config
31 OnEHLO() *ReplyLine
32 OnMessageDelivered(Envelope) *ReplyLine
33 }
34
35 type EmptyServerCallbacks struct {}
36
37 func (*EmptyServerCallbacks) TLSConfig() *tls.Config {
38 return nil
39 }
40
41 func (*EmptyServerCallbacks) OnEHLO() *ReplyLine {
42 return nil
43 }
44
45 func (*EmptyServerCallbacks) OnMessageDelivered(Envelope) *ReplyLine {
46 return nil
47 }