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 OnMessageDelivered(Envelope) *ReplyLine
60 type EmptyServerCallbacks struct{}
62 func (*EmptyServerCallbacks) TLSConfig() *tls.Config {
66 func (*EmptyServerCallbacks) VerifyAddress(mail.Address) ReplyLine {
70 func (*EmptyServerCallbacks) OnMessageDelivered(Envelope) *ReplyLine {