1//go:build ignore2// +build ignore34// Copy that file into target/ subdirectory.56package target_name78/*9Maddy Mail Server - Composable all-in-one email server.10Copyright © 2019-2021 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors1112This program is free software: you can redistribute it and/or modify13it under the terms of the GNU General Public License as published by14the Free Software Foundation, either version 3 of the License, or15(at your option) any later version.1617This program is distributed in the hope that it will be useful,18but WITHOUT ANY WARRANTY; without even the implied warranty of19MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the20GNU General Public License for more details.2122You should have received a copy of the GNU General Public License23along with this program. If not, see <https://www.gnu.org/licenses/>.24*/2526import (27 "context"2829 "github.com/emersion/go-message/textproto"30 "github.com/foxcpp/maddy/framework/buffer"31 "github.com/foxcpp/maddy/framework/config"32 "github.com/foxcpp/maddy/framework/log"33 "github.com/foxcpp/maddy/framework/module"34)3536const modName = "target.target_name"3738type Target struct {39 instName string40 log log.Logger41}4243func New(_, instName string, _, inlineArgs []string) (module.Module, error) {44 // If wanted, extract any values from inlineArgs (these values:45 // deliver_to target_name ARG1 ARG2 { ... }4647 return &Target{48 instName: instName,49 log: log.Logger{Name: instName},50 }, nil51}5253func (t *Target) Init(cfg *config.Map) error {54 cfg.Bool("debug", true, false, &t.log.Debug)5556 // Read any config directives into Target variables here.5758 if _, err := cfg.Process(); err != nil {59 return err60 }6162 // Finish setup using obtained values.6364 return nil65}6667func (t *Target) Name() string {68 return modName69}7071func (t *Target) InstanceName() string {72 return t.instName73}7475// If it necessary to have any server shutdown cleanup - implement Close.7677func (t *Target) Close() error {78 return nil79}8081type delivery struct {82 t *Target83 mailFrom string84 log log.Logger85 msgMeta *module.MsgMetadata86}8788/*89See module.DeliveryTarget and module.Delivery docs for details on each method.90*/9192func (t *Target) Start(ctx context.Context, msgMeta *module.MsgMetadata, mailFrom string) (module.Delivery, error) {93 return &delivery{94 t: t,95 mailFrom: mailFrom,96 log: DeliveryLogger(t.log, msgMeta),97 msgMeta: msgMeta,98 }, nil99}100101func (d *delivery) AddRcpt(ctx context.Context, rcptTo string) error {102 // Corresponds to SMTP RCPT command.103 panic("implement me")104}105106func (d *delivery) Body(ctx context.Context, header textproto.Header, body buffer.Buffer) error {107 // Corresponds to SMTP DATA command.108 panic("implement me")109}110111/*112If Body call can fail partially (either success or fail for each recipient passed to AddRcpt)113- implement BodyNonAtomic and signal status for each recipient using StatusCollector callback.114115func (d *delivery) BodyNonAtomic(ctx context.Context, sc module.StatusCollector, header textproto.Header, body buffer.Buffer) {116117}118*/119120func (d *delivery) Abort(ctx context.Context) error {121 panic("implement me")122}123124func (d *delivery) Commit(ctx context.Context) error {125 panic("implement me")126}127128func init() {129 module.Register(modName, New)130}