email

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmailConfig

type EmailConfig struct {
	Host     string
	Port     int
	Username string
	Password string
	From     string
}

type EmailRequest

type EmailRequest struct {
	To      []string
	Subject string
	Body    string
	IsHTML  bool
}

type EmailService

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

func NewEmailService

func NewEmailService(config EmailConfig) *EmailService

func (*EmailService) Close

func (e *EmailService) Close()

Close gracefully shuts down the email service

func (*EmailService) GetQueueLength

func (e *EmailService) GetQueueLength() int

GetQueueLength returns the current number of emails in the queue

func (*EmailService) SendBulkEmail

func (e *EmailService) SendBulkEmail(emails []string, subject, htmlContent string) error

SendBulkEmail sends email to multiple recipients asynchronously (for announcements)

func (*EmailService) SendOTPEmail

func (e *EmailService) SendOTPEmail(email, firstName, otp string) error

SendOTPEmail sends OTP verification email asynchronously (Django's send_register_otp equivalent)

func (*EmailService) SendPasswordResetEmail

func (e *EmailService) SendPasswordResetEmail(email, resetLink string) error

SendPasswordResetEmail sends password reset email asynchronously

func (*EmailService) SendWelcomeEmail

func (e *EmailService) SendWelcomeEmail(email, firstName string) error

SendWelcomeEmail sends welcome email after verification asynchronously

func (*EmailService) TestEmailConnection

func (e *EmailService) TestEmailConnection() error

TestEmailConnection tests the email service configuration

type EmailServiceInterface

type EmailServiceInterface interface {
	SendOTPEmail(email, firstName, otp string) error
	SendWelcomeEmail(email, firstName string) error
	SendPasswordResetEmail(email, resetLink string) error
	SendBulkEmail(emails []string, subject, htmlContent string) error
	TestEmailConnection() error
	GetQueueLength() int
}

EmailServiceInterface defines the interface for email operations

func NewEmailServiceFactory

func NewEmailServiceFactory(config EmailConfig, useLocal bool, logFilePath string) (EmailServiceInterface, error)

NewEmailServiceFactory creates email service based on environment configuration

type LocalEmailService

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

LocalEmailService implements EmailServiceInterface for local development Instead of sending emails, it logs them to a file for testing purposes

func NewLocalEmailService

func NewLocalEmailService(logFilePath string) (*LocalEmailService, error)

NewLocalEmailService creates a new local email service that logs to file

func (*LocalEmailService) Close

func (l *LocalEmailService) Close() error

Close closes the log file

func (*LocalEmailService) GetQueueLength

func (l *LocalEmailService) GetQueueLength() int

GetQueueLength returns 0 for local service (no actual queue)

func (*LocalEmailService) SendBulkEmail

func (l *LocalEmailService) SendBulkEmail(emails []string, subject, htmlContent string) error

SendBulkEmail logs bulk email details

func (*LocalEmailService) SendOTPEmail

func (l *LocalEmailService) SendOTPEmail(email, firstName, otp string) error

SendOTPEmail logs OTP email details instead of sending

func (*LocalEmailService) SendPasswordResetEmail

func (l *LocalEmailService) SendPasswordResetEmail(email, resetLink string) error

SendPasswordResetEmail logs password reset email details

func (*LocalEmailService) SendWelcomeEmail

func (l *LocalEmailService) SendWelcomeEmail(email, firstName string) error

SendWelcomeEmail logs welcome email details

func (*LocalEmailService) TestEmailConnection

func (l *LocalEmailService) TestEmailConnection() error

TestEmailConnection always returns success for local service

type OTPEmailData

type OTPEmailData struct {
	Name string
	OTP  string
}

Jump to

Keyboard shortcuts

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