email

package
v1.0.53 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTemplateData

func BuildTemplateData(configData map[string]string, toAddress string) map[string]interface{}

BuildTemplateData builds template data from config values only

Types

type Config

type Config struct {
	Enabled     bool
	APIKey      string
	FromAddress string
	ReplyTo     string
}

Config holds the email client configuration

type Email

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

EmailService handles email operations

func NewEmail

func NewEmail(client *EmailClient, logger *zap.Logger) *Email

NewEmailService creates a new email service

func (*Email) SendEmail

func (s *Email) SendEmail(ctx context.Context, req SendEmailRequest) (*SendEmailResponse, error)

SendEmail sends a plain text email

func (*Email) SendEmailWithTemplate

SendEmailWithTemplate sends an email using an HTML template

type EmailClient

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

EmailClient represents an email client wrapper

func NewEmailClient

func NewEmailClient(cfg Config) *EmailClient

NewEmailClient creates a new email client

func (*EmailClient) GetFromAddress

func (c *EmailClient) GetFromAddress() string

GetFromAddress returns the default from address

func (*EmailClient) GetReplyTo

func (c *EmailClient) GetReplyTo() string

GetReplyTo returns the default reply-to address

func (*EmailClient) IsEnabled

func (c *EmailClient) IsEnabled() bool

IsEnabled returns whether the email client is enabled

func (*EmailClient) SendEmail

func (c *EmailClient) SendEmail(ctx context.Context, from, to, subject, htmlContent, textContent string) (string, error)

SendEmail sends a plain text or HTML email

type SendEmailRequest

type SendEmailRequest struct {
	FromAddress string `json:"from_address" validate:"omitempty,email" example:"noreply@flexprice.io"`
	ToAddress   string `json:"to_address" validate:"required,email" example:"user@example.com"`
	Subject     string `json:"subject" validate:"required" example:"Welcome to Flexprice"`
	Text        string `json:"text" validate:"required" example:"Hello, welcome to our platform!"`
}

SendEmailRequest represents a request to send a plain text email Example:

{
	"from_address": "subrat@flexprice.io",
	"to_address": "client@example.com",
	"subject": "Welcome to Flexprice",
	"text": "Hello, welcome to our platform!"
}

type SendEmailResponse

type SendEmailResponse struct {
	MessageID string
	Success   bool
	Error     string
}

SendEmailResponse represents the response from sending an email

type SendEmailWithTemplateRequest

type SendEmailWithTemplateRequest struct {
	FromAddress  string                 `json:"from_address" validate:"omitempty,email"`
	ToAddress    string                 `json:"to_address" validate:"required,email"`
	Subject      string                 `json:"subject" validate:"required"`
	TemplatePath string                 `json:"template_path" validate:"required"`
	Data         map[string]interface{} `json:"data" validate:"omitempty"`
}

SendEmailWithTemplateRequest represents a request to send an email with a template Data field is optional - if not provided or partially provided, values from config will be used Example:

{
	"from_address": "subrat@flexprice.io",
	"to_address": "client@example.com",
	"subject": "Welcome to Flexprice!",
	"template_path": "welcome-email.html",
	"data": {
		"calendar_url": "https://calendly.com/flexprice-30mins-chat/manish?month=2025-03"
	}
}

type SendEmailWithTemplateResponse

type SendEmailWithTemplateResponse struct {
	MessageID string
	Success   bool
	Error     string
}

SendEmailWithTemplateResponse represents the response from sending a templated email

Jump to

Keyboard shortcuts

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