1/*2Maddy Mail Server - Composable all-in-one email server.3Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors45This program is free software: you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation, either version 3 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program. If not, see <https://www.gnu.org/licenses/>.17*/1819package module2021import (22 "context"2324 "github.com/emersion/go-message/textproto"25 "github.com/emersion/go-smtp"26 "github.com/foxcpp/maddy/framework/buffer"27 "github.com/foxcpp/maddy/framework/config"28)2930// Dummy is a struct that implements PlainAuth and DeliveryTarget31// interfaces but does nothing. Useful for testing.32//33// It is always registered under the 'dummy' name and can be used in both tests34// and the actual server code (but the latter is kinda pointless).35type Dummy struct{ instName string }3637func (d *Dummy) AuthPlain(username, _ string) error {38 return nil39}4041func (d *Dummy) Lookup(_ context.Context, _ string) (string, bool, error) {42 return "", false, nil43}4445func (d *Dummy) LookupMulti(_ context.Context, _ string) ([]string, error) {46 return []string{""}, nil47}4849func (d *Dummy) Name() string {50 return "dummy"51}5253func (d *Dummy) InstanceName() string {54 return d.instName55}5657func (d *Dummy) Init(_ *config.Map) error {58 return nil59}6061func (d *Dummy) Start(ctx context.Context, msgMeta *MsgMetadata, mailFrom string) (Delivery, error) {62 return dummyDelivery{}, nil63}6465type dummyDelivery struct{}6667func (dd dummyDelivery) AddRcpt(ctx context.Context, rcptTo string, opts smtp.RcptOptions) error {68 return nil69}7071func (dd dummyDelivery) Body(ctx context.Context, header textproto.Header, body buffer.Buffer) error {72 return nil73}7475func (dd dummyDelivery) Abort(ctx context.Context) error {76 return nil77}7879func (dd dummyDelivery) Commit(ctx context.Context) error {80 return nil81}8283func init() {84 Register("dummy", func(_, instName string, _, _ []string) (Module, error) {85 return &Dummy{instName: instName}, nil86 })87}