2 // Copyright 2020 Blue Static <https://www.bluestatic.org>
3 // This program is free software licensed under the GNU General Public License,
4 // version 3.0. The full text of the license can be found in LICENSE.txt.
5 // SPDX-License-Identifier: GPL-3.0-only
18 type ReplyLine struct {
23 func (l ReplyLine) String() string {
24 return fmt.Sprintf("%d %s", l.Code, l.Message)
28 ReplyOK = ReplyLine{250, "OK"}
29 ReplyBadSyntax = ReplyLine{501, "syntax error"}
30 ReplyBadSequence = ReplyLine{503, "bad sequence of commands"}
31 ReplyBadMailbox = ReplyLine{550, "mailbox unavailable"}
34 type Envelope struct {
44 func WriteEnvelopeForDelivery(w io.Writer, e Envelope) {
45 fmt.Fprintf(w, "Delivered-To: <%s>\r\n", e.RcptTo[0].Address)
46 fmt.Fprintf(w, "Return-Path: <%s>\r\n", e.MailFrom.Address)
50 type Server interface {
52 TLSConfig() *tls.Config
54 VerifyAddress(mail.Address) ReplyLine
55 OnMessageDelivered(Envelope) *ReplyLine
58 type EmptyServerCallbacks struct{}
60 func (*EmptyServerCallbacks) TLSConfig() *tls.Config {
64 func (*EmptyServerCallbacks) OnEHLO() *ReplyLine {
68 func (*EmptyServerCallbacks) VerifyAddress(mail.Address) ReplyLine {
72 func (*EmptyServerCallbacks) OnMessageDelivered(Envelope) *ReplyLine {