Documentation
¶
Overview ¶
Catalog stock notifications: the commerce sends the platform offers out of the box. The service stays module-agnostic — the bucket details arrive as display-ready values composed by the caller.
Order email notifications: the commerce sends the platform offers out of the box. The service stays module-agnostic — item lines arrive as display-ready strings composed by the caller.
Payment email notifications: the commerce sends the platform offers out of the box. The service stays module-agnostic — the record details arrive as display-ready strings composed by the caller.
Index ¶
- type EmailService
- type ManualPayee
- type OrderEmailItem
- type SMTPConfig
- type Service
- func (s *Service) IsEnabled() bool
- func (s *Service) SendAccountCreatedEmail(ctx context.Context, to, username, plainPassword string) error
- func (s *Service) SendAccountDeletedNotification(ctx context.Context, to, username string) error
- func (s *Service) SendAccountLockoutEmail(ctx context.Context, to, username string) error
- func (s *Service) SendDataExportNotificationEmail(ctx context.Context, to, username string) error
- func (s *Service) SendEmailUpdateVerificationEmail(ctx context.Context, to, username, token string) error
- func (s *Service) SendLowStockAlert(ctx context.Context, to string, contentID int, sku string, stock int, ...) error
- func (s *Service) SendMFACodeEmail(ctx context.Context, to, username, code string) error
- func (s *Service) SendNewOrderAlert(ctx context.Context, to string, orderNumber string, customerName string, ...) error
- func (s *Service) SendOrderConfirmationEmail(ctx context.Context, to, orderNumber string, items []OrderEmailItem, ...) error
- func (s *Service) SendOrderStatusEmail(ctx context.Context, to, orderNumber, status string) error
- func (s *Service) SendPasswordResetEmail(ctx context.Context, to, username, token string) error
- func (s *Service) SendPaymentProofAlert(ctx context.Context, to string, orderNumber string, customerEmail string, ...) error
- func (s *Service) SendPaymentReceivedEmail(ctx context.Context, to, orderNumber, method, reference, amount string) error
- func (s *Service) SendPaymentRejectedEmail(ctx context.Context, to, orderNumber, method, reference string) error
- func (s *Service) SendPaymentSettledAlert(ctx context.Context, to string, orderNumber string, customerEmail string, ...) error
- func (s *Service) SendRegistrationAttemptEmail(ctx context.Context, to, username string) error
- func (s *Service) SendUserApprovedEmail(ctx context.Context, to, username string) error
- func (s *Service) SendUserRejectedEmail(ctx context.Context, to, username string) error
- func (s *Service) SendUserSoftDeletedEmail(ctx context.Context, to, username, reason string) error
- func (s *Service) SendUserSuspendedEmail(ctx context.Context, to, username, reason string) error
- func (s *Service) SendUserUnsuspendedEmail(ctx context.Context, to, username string) error
- func (s *Service) SendVerificationEmail(ctx context.Context, to, username, token string) error
- func (s *Service) SetBaseURL(baseURL string)
- func (s *Service) SetPrivacyPolicyURL(url string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmailService ¶
type EmailService interface {
SendVerificationEmail(ctx context.Context, to, username, token string) error
SendAccountLockoutEmail(ctx context.Context, to, username string) error
SendRegistrationAttemptEmail(ctx context.Context, to, username string) error
SendUserApprovedEmail(ctx context.Context, to, username string) error
SendUserRejectedEmail(ctx context.Context, to, username string) error
SendUserSuspendedEmail(ctx context.Context, to, username, reason string) error
SendUserUnsuspendedEmail(ctx context.Context, to, username string) error
SendUserSoftDeletedEmail(ctx context.Context, to, username, reason string) error
SendEmailUpdateVerificationEmail(ctx context.Context, to, username, token string) error
SendDataExportNotificationEmail(ctx context.Context, to, username string) error
SendAccountDeletedNotification(ctx context.Context, to, username string) error
SendAccountCreatedEmail(ctx context.Context, to, username, plainPassword string) error
SendPasswordResetEmail(ctx context.Context, to, username, token string) error
SendMFACodeEmail(ctx context.Context, to, username, code string) error
}
EmailService defines the interface for email operations
type ManualPayee ¶ added in v1.1.0
ManualPayee is the destination account for manual bank transfers, adopted from the [payments.manual] config block. Empty means no payee block is configured and the confirmation email carries no How-to-pay section.
type OrderEmailItem ¶ added in v1.1.0
type OrderEmailItem struct {
SKU string
Title string
Quantity int
UnitPrice string
LineTotal string
}
OrderEmailItem is one purchase line of an order email. SKU and money amounts arrive as display-ready strings so the email service needs no commerce knowledge.
type SMTPConfig ¶
SMTPConfig contains SMTP configuration
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles email sending operations
func NewService ¶
func NewService(config SMTPConfig, logger *slog.Logger, baseURL string) *Service
NewService creates a new email service
func (*Service) SendAccountCreatedEmail ¶
func (s *Service) SendAccountCreatedEmail(ctx context.Context, to, username, plainPassword string) error
SendAccountCreatedEmail sends a welcome email to a newly admin-created user with credentials
func (*Service) SendAccountDeletedNotification ¶
SendAccountDeletedNotification sends an account deletion notification email to a user
func (*Service) SendAccountLockoutEmail ¶
SendAccountLockoutEmail sends an account lockout notification email to a user
func (*Service) SendDataExportNotificationEmail ¶
SendDataExportNotificationEmail sends a data export notification email to a user
func (*Service) SendEmailUpdateVerificationEmail ¶
func (s *Service) SendEmailUpdateVerificationEmail(ctx context.Context, to, username, token string) error
SendEmailUpdateVerificationEmail sends an email update verification email to a user
func (*Service) SendLowStockAlert ¶ added in v1.1.0
func (s *Service) SendLowStockAlert(ctx context.Context, to string, contentID int, sku string, stock int, threshold int) error
SendLowStockAlert tells the operator one tracked bucket crossed its threshold downward.
func (*Service) SendMFACodeEmail ¶ added in v1.1.0
SendMFACodeEmail sends the one-time login verification code to a user.
func (*Service) SendNewOrderAlert ¶ added in v1.7.1
func (s *Service) SendNewOrderAlert( ctx context.Context, to string, orderNumber string, customerName string, customerEmail string, customerPhone string, shipTo string, items []OrderEmailItem, subtotal string, shipping string, total string, ) error
SendNewOrderAlert tells the operator a new order was placed, carrying the customer contact, the shipping address, and the frozen totals. The address and money amounts arrive display-ready, so the email service needs no commerce knowledge.
func (*Service) SendOrderConfirmationEmail ¶ added in v1.1.0
func (s *Service) SendOrderConfirmationEmail(ctx context.Context, to, orderNumber string, items []OrderEmailItem, subtotal string, shipping string, total string, payee ManualPayee, trackingToken string) error
SendOrderConfirmationEmail sends the confirmation for a just-placed order. A set payee appends the How-to-pay block; an empty payee sends the legacy body unchanged. A non-empty trackingToken appends the Track-your-order link built from the site base URL — the token is the order's guest key, so the email is the only place it is delivered.
func (*Service) SendOrderStatusEmail ¶ added in v1.1.0
SendOrderStatusEmail tells the customer one lifecycle move of their placed order, carrying the new status as its display string.
func (*Service) SendPasswordResetEmail ¶
SendPasswordResetEmail sends a password reset email to a user
func (*Service) SendPaymentProofAlert ¶ added in v1.7.1
func (s *Service) SendPaymentProofAlert( ctx context.Context, to string, orderNumber string, customerEmail string, method string, reference string, amount string, ) error
SendPaymentProofAlert tells the operator a manual payment proof was submitted and needs verification, carrying the reference to check and the expected amount. The amount arrives display-ready, so the email service needs no commerce knowledge.
func (*Service) SendPaymentReceivedEmail ¶ added in v1.1.0
func (s *Service) SendPaymentReceivedEmail(ctx context.Context, to, orderNumber, method, reference, amount string) error
SendPaymentReceivedEmail confirms a submitted payment proof for a placed order.
func (*Service) SendPaymentRejectedEmail ¶ added in v1.1.0
func (s *Service) SendPaymentRejectedEmail(ctx context.Context, to, orderNumber, method, reference string) error
SendPaymentRejectedEmail tells the customer their proof could not be verified and how to correct it.
func (*Service) SendPaymentSettledAlert ¶ added in v1.7.1
func (s *Service) SendPaymentSettledAlert( ctx context.Context, to string, orderNumber string, customerEmail string, method string, amount string, ) error
SendPaymentSettledAlert tells the operator a gateway payment settled, so the order is paid and ready to fulfill. The amount arrives display-ready, so the email service needs no commerce knowledge.
func (*Service) SendRegistrationAttemptEmail ¶ added in v1.1.0
SendRegistrationAttemptEmail notifies an existing account holder that a registration attempt collided with their username or email. It backs the anti-enumeration registration contract: the requester always gets the same generic response, and the real owner is the one who finds out.
func (*Service) SendUserApprovedEmail ¶
SendUserApprovedEmail sends an email when a user's registration is approved
func (*Service) SendUserRejectedEmail ¶
SendUserRejectedEmail sends an email when a user's registration is rejected
func (*Service) SendUserSoftDeletedEmail ¶
SendUserSoftDeletedEmail sends an email when a user's account is soft deleted
func (*Service) SendUserSuspendedEmail ¶
SendUserSuspendedEmail sends an email when a user's account is suspended
func (*Service) SendUserUnsuspendedEmail ¶
SendUserUnsuspendedEmail sends an email when a user's account is unsuspended
func (*Service) SendVerificationEmail ¶
SendVerificationEmail sends a verification email to a user
func (*Service) SetBaseURL ¶
SetBaseURL sets the base URL for verification links
func (*Service) SetPrivacyPolicyURL ¶ added in v1.1.0
SetPrivacyPolicyURL adopts the resolved privacy-policy link for the email footer. An empty URL leaves the footer unchanged: the store publishes no privacy policy, so there is nothing to link.