31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
// Package disabled provides the mail transport for EMAIL_PROVIDER=disabled.
|
|
package disabled
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"lincodex/backend/internal/port/outbound"
|
|
)
|
|
|
|
// Sender sends nothing. Every valid message is reported as
|
|
// outbound.ErrMailChannelUnavailable, never as an accepted or delivered
|
|
// message, so a caller cannot mistake the disabled mode for a delivery.
|
|
type Sender struct{}
|
|
|
|
var _ outbound.MailSender = (*Sender)(nil)
|
|
|
|
func NewSender() *Sender {
|
|
return &Sender{}
|
|
}
|
|
|
|
// Send validates the message first so that local runs without a transport
|
|
// still expose invalid messages, then reports the channel as unavailable. It
|
|
// logs nothing and keeps no copy of the recipient or the content.
|
|
func (sender *Sender) Send(_ context.Context, mail outbound.OutgoingMail) (outbound.SendResult, error) {
|
|
if err := mail.Validate(); err != nil {
|
|
return outbound.SendResult{}, fmt.Errorf("Sender.Send - validate mail: %w", err)
|
|
}
|
|
return outbound.SendResult{}, fmt.Errorf("Sender.Send - EMAIL_PROVIDER is disabled: %w", outbound.ErrMailChannelUnavailable)
|
|
}
|