email

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled    bool             `json:"enabled"`
	Provider   string           `json:"provider"` // "smtp", "sendgrid", "ses", "mailersend"
	SMTP       SMTPConfig       `json:"smtp"`
	SendGrid   SendGridConfig   `json:"sendgrid"`
	SES        SESConfig        `json:"ses"`
	MailerSend MailerSendConfig `json:"mailersend"`
	Sender     SenderConfig     `json:"sender"`
	BaseURL    string           `json:"baseURL"` // Base URL for web console
	Templates  TemplatesConfig  `json:"templates"`
}

Config represents the email service configuration

type MailerSendConfig

type MailerSendConfig struct {
	APIKey string `json:"apiKey"`
}

MailerSendConfig represents MailerSend API configuration

type MailerSendService

type MailerSendService struct {
	// contains filtered or unexported fields
}

MailerSendService implements Service using MailerSend

func (*MailerSendService) SendWelcomeEmail

func (s *MailerSendService) SendWelcomeEmail(ctx context.Context, to string, language string) error

type NoOpService

type NoOpService struct {
	// contains filtered or unexported fields
}

NoOpService is a no-operation email service for testing or when email is disabled

func (*NoOpService) SendWelcomeEmail

func (s *NoOpService) SendWelcomeEmail(ctx context.Context, to string, language string) error

type SESConfig

type SESConfig struct {
	Region    string `json:"region"`
	AccessKey string `json:"accessKey"`
	SecretKey string `json:"secretKey"`
}

SESConfig represents Amazon SES configuration

type SESService

type SESService struct {
	// contains filtered or unexported fields
}

SESService implements Service using Amazon SES

func (*SESService) SendWelcomeEmail

func (s *SESService) SendWelcomeEmail(ctx context.Context, to string, language string) error

type SMTPConfig

type SMTPConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Username string `json:"username"`
	Password string `json:"password"`
}

SMTPConfig represents SMTP server configuration

type SMTPService

type SMTPService struct {
	// contains filtered or unexported fields
}

SMTPService implements Service using SMTP

func (*SMTPService) SendWelcomeEmail

func (s *SMTPService) SendWelcomeEmail(ctx context.Context, to string, language string) error

type SendGridConfig

type SendGridConfig struct {
	APIKey string `json:"apiKey"`
}

SendGridConfig represents SendGrid API configuration

type SendGridService

type SendGridService struct {
	// contains filtered or unexported fields
}

SendGridService implements Service using SendGrid

func (*SendGridService) SendWelcomeEmail

func (s *SendGridService) SendWelcomeEmail(ctx context.Context, to string, language string) error

type SenderConfig

type SenderConfig struct {
	Email string `json:"email"`
	Name  string `json:"name"`
}

SenderConfig represents the sender's email and name

type Service

type Service interface {
	SendWelcomeEmail(ctx context.Context, to string, language string) error
}

Service defines the interface for sending emails

func NewMailerSendService

func NewMailerSendService(config Config, logger *zap.Logger) Service

NewMailerSendService creates a new MailerSend email service

func NewNoOpService

func NewNoOpService(logger *zap.Logger) Service

NewNoOpService creates a no-operation email service

func NewSESService

func NewSESService(emailConfig Config, logger *zap.Logger) (Service, error)

NewSESService creates a new SES email service

func NewSMTPService

func NewSMTPService(config Config, logger *zap.Logger) Service

NewSMTPService creates a new SMTP email service

func NewSendGridService

func NewSendGridService(config Config, logger *zap.Logger) Service

NewSendGridService creates a new SendGrid email service

func NewService

func NewService(config Config, logger *zap.Logger) (Service, error)

NewService creates an email service based on configuration

type Template

type Template struct {
	Subject string `json:"subject"`
	Body    string `json:"body"`
}

Template represents a single email template with subject and body

type TemplateRenderer

type TemplateRenderer struct {
	// contains filtered or unexported fields
}

TemplateRenderer handles email template rendering with variable substitution

func NewTemplateRenderer

func NewTemplateRenderer(config Config) *TemplateRenderer

NewTemplateRenderer creates a new template renderer

func (*TemplateRenderer) RenderWelcomeEmail

func (r *TemplateRenderer) RenderWelcomeEmail(
	language string,
	userEmail string,
) (subject, body string)

RenderWelcomeEmail renders the welcome email template

type TemplatesByLanguage

type TemplatesByLanguage struct {
	Welcome Template `json:"welcome"`
}

TemplatesByLanguage represents email templates for a specific language

type TemplatesConfig

type TemplatesConfig struct {
	En TemplatesByLanguage `json:"en"`
	Ja TemplatesByLanguage `json:"ja"`
}

TemplatesConfig represents email templates for all supported languages

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址