]>
src.bluestatic.org Git - mailpopbox.git/blob - smtp/server.go
13 type ReplyLine
struct {
18 func (l ReplyLine
) String() string {
19 return fmt
.Sprintf("%d %s", l
.Code
, l
.Message
)
23 ReplyOK
= ReplyLine
{250, "OK"}
24 ReplyBadSyntax
= ReplyLine
{501, "syntax error"}
25 ReplyBadSequence
= ReplyLine
{503, "bad sequence of commands"}
26 ReplyBadMailbox
= ReplyLine
{550, "mailbox unavailable"}
29 func DomainForAddress(addr mail
.Address
) string {
30 domainIdx
:= strings
.LastIndex(addr
.Address
, "@")
34 return addr
.Address
[domainIdx
+1:]
37 type Envelope
struct {
47 func WriteEnvelopeForDelivery(w io
.Writer
, e Envelope
) {
48 fmt
.Fprintf(w
, "Delivered-To: <%s>\r\n", e
.RcptTo
[0].Address
)
49 fmt
.Fprintf(w
, "Return-Path: <%s>\r\n", e
.MailFrom
.Address
)
53 type Server
interface {
55 TLSConfig() *tls
.Config
56 VerifyAddress(mail
.Address
) ReplyLine
57 // Verify that the authc+passwd identity can send mail as authz.
58 Authenticate(authz
, authc
, passwd
string) bool
59 OnMessageDelivered(Envelope
) *ReplyLine
62 type EmptyServerCallbacks
struct{}
64 func (*EmptyServerCallbacks
) TLSConfig() *tls
.Config
{
68 func (*EmptyServerCallbacks
) VerifyAddress(mail
.Address
) ReplyLine
{
72 func (*EmptyServerCallbacks
) Authenticate(authz
, authc
, passwd
string) bool {
76 func (*EmptyServerCallbacks
) OnMessageDelivered(Envelope
) *ReplyLine
{