email

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupExpiredTokens added in v0.45.0

func CleanupExpiredTokens(db *sql.DB) (int64, error)

CleanupExpiredTokens deletes expired and unused tokens from the database. Returns the number of tokens deleted.

func GenerateResetToken added in v0.45.0

func GenerateResetToken(userID int64) (string, time.Time, error)

GenerateResetToken generates a new random reset token for the given user ID. Returns the token string, expiration time, and any error.

func IsSMTPEnabled added in v0.38.0

func IsSMTPEnabled(db *sql.DB) bool

IsSMTPEnabled checks if SMTP is enabled in settings

func LoadTemplate added in v0.45.0

func LoadTemplate(name string) (string, error)

func MarkTokenUsed added in v0.45.0

func MarkTokenUsed(db *sql.DB, token string) error

MarkTokenUsed marks a reset token as used by setting the used_at timestamp.

func SaveResetToken added in v0.45.0

func SaveResetToken(db *sql.DB, userID int64, token string, expiresAt time.Time) error

SaveResetToken saves a password reset token to the database.

func SendAdminNotification

func SendAdminNotification(ctx context.Context, adminEmail, userName, userEmail, companyName, lang string, db *sql.DB) error

SendAdminNotification sends a notification email to an admin

func SendEmail added in v0.45.0

func SendEmail(ctx context.Context, msg *mail.Msg, db *sql.DB) error

SendEmail sends an email using Mailtrap SMTP configuration

func SendReport added in v0.46.0

func SendReport(ctx context.Context, to string, contracts []reports.Contract, db *sql.DB) error

SendReport sends a contract report email with PDF attachment

func SendVerificationCode

func SendVerificationCode(ctx context.Context, to, code, lang string, db *sql.DB) error

SendVerificationCode sends a verification code email to the user

func SendWithMailtrap added in v0.45.0

func SendWithMailtrap(ctx context.Context, msg *mail.Msg, cfg SMTPConfig) error

SendWithMailtrap sends email using Mailtrap SMTP

func ValidateResetToken added in v0.45.0

func ValidateResetToken(db *sql.DB, token string) (int64, error)

ValidateResetToken validates a password reset token. Checks that the token exists, has not been used (usedAt IS NULL), and has not expired. Returns the user ID associated with the token, or an error.

Types

type EmailTemplate added in v0.33.0

type EmailTemplate struct {
	Subject string
	HTML    string
}

EmailTemplate holds localized email content

func GetAdminNotificationTemplate added in v0.33.0

func GetAdminNotificationTemplate(lang, userName, userEmail, companyName string) EmailTemplate

GetAdminNotificationTemplate returns the localized admin notification template

func GetContractExpiryTemplate added in v0.45.0

func GetContractExpiryTemplate(contractNumber, daysLeft, expiryDate, contractName, clientName, companyName, contractID, adminEmail string) EmailTemplate

GetContractExpiryTemplate returns the contract expiry notification template

func GetPasswordResetTemplate added in v0.45.0

func GetPasswordResetTemplate(lang, resetLink, userName string) EmailTemplate

GetPasswordResetTemplate returns the localized password reset email template

func GetReportTemplate added in v0.45.0

func GetReportTemplate(reportDate string) EmailTemplate

GetReportTemplate returns the report email template

func GetVerificationTemplate added in v0.33.0

func GetVerificationTemplate(lang, code string) EmailTemplate

GetVerificationTemplate returns the localized verification email template

type SMTPConfig added in v0.45.0

type SMTPConfig struct {
	Host string
	Port int
	User string
	Pass string
	From string
}

SMTPConfig holds the configuration for Mailtrap SMTP client

func GetSMTPConfig added in v0.45.0

func GetSMTPConfig(db *sql.DB) (SMTPConfig, error)

GetSMTPConfig loads SMTP configuration from database or environment

Jump to

Keyboard shortcuts

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