26 lines
742 B
Go
26 lines
742 B
Go
|
|
package usecase
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"apps/backend/internal/module/notification/domain"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
// LogDelivery — no SMTP; logs that a mail would be sent (local/dev).
|
||
|
|
type LogDelivery struct{}
|
||
|
|
|
||
|
|
func NewLogDelivery() *LogDelivery { return &LogDelivery{} }
|
||
|
|
|
||
|
|
func (d *LogDelivery) Name() string { return "log" }
|
||
|
|
|
||
|
|
func (d *LogDelivery) SendEmail(ctx context.Context, req domain.EmailRequest) error {
|
||
|
|
// Do not log full body in production logs if code is inside; still useful for dev.
|
||
|
|
logx.WithContext(ctx).Infof(
|
||
|
|
"[mail:log] to=%s from=%s subject=%q body_len=%d (SMTP not configured — mail not actually sent)",
|
||
|
|
req.RecipientEmail, req.SenderEmail, req.Subject, len(req.HTMLBody),
|
||
|
|
)
|
||
|
|
return nil
|
||
|
|
}
|