]> src.bluestatic.org Git - mailpopbox.git/blob - smtp/server.go
Fix case sensitivity in the POP3 sever.
[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 ReplyBadMailbox = ReplyLine{550, "mailbox unavailable"}
19 )
20
21 type Envelope struct {
22 RemoteAddr net.Addr
23 EHLO string
24 MailFrom mail.Address
25 RcptTo []mail.Address
26 Data []byte
27 }
28
29 type Server interface {
30 Name() string
31 TLSConfig() *tls.Config
32 OnEHLO() *ReplyLine
33 VerifyAddress(mail.Address) ReplyLine
34 OnMessageDelivered(Envelope) *ReplyLine
35 }
36
37 type EmptyServerCallbacks struct {}
38
39 func (*EmptyServerCallbacks) TLSConfig() *tls.Config {
40 return nil
41 }
42
43 func (*EmptyServerCallbacks) OnEHLO() *ReplyLine {
44 return nil
45 }
46
47 func (*EmptyServerCallbacks) VerifyAddress(mail.Address) ReplyLine {
48 return ReplyOK
49 }
50
51 func (*EmptyServerCallbacks) OnMessageDelivered(Envelope) *ReplyLine {
52 return nil
53 }