email

package
v0.0.0-...-a962597 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Apache-2.0 Imports: 10 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 {
	Provider       string // "sendgrid" or "resend"
	SendGridAPIKey string // SendGrid API key
	ResendAPIKey   string // Resend API key
	FromEmail      string // From email address for all providers
}

Config are configurations options for the service

type EmailProvider

type EmailProvider interface {
	SendEmail(ctx context.Context, options SendOptions) error
}

EmailProvider defines the interface that all email providers must implement

type ProviderType

type ProviderType string

ProviderType represents the available email providers

const (
	ProviderSendGrid ProviderType = "sendgrid"
	ProviderResend   ProviderType = "resend"
)

Email provider constants

func ProviderTypeFrom

func ProviderTypeFrom(s string) ProviderType

ProviderTypeFrom converts a string to a ProviderType, defaulting to SendGrid

type Recipient

type Recipient struct {
	Name  string
	Email string
}

Recipient represents a user

type ResendProvider

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

ResendProvider implements the EmailProvider interface for Resend

func NewResendProvider

func NewResendProvider(apiKey, fromEmail string) *ResendProvider

NewResendProvider creates a new Resend email provider

func (*ResendProvider) SendEmail

func (p *ResendProvider) SendEmail(ctx context.Context, options SendOptions) error

SendEmail sends an email using Resend

type SendGridProvider

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

SendGridProvider implements the EmailProvider interface for SendGrid

func NewSendGridProvider

func NewSendGridProvider(apiKey, fromEmail string) *SendGridProvider

NewSendGridProvider creates a new SendGrid email provider

func (*SendGridProvider) SendEmail

func (p *SendGridProvider) SendEmail(ctx context.Context, options SendOptions) error

SendEmail sends an email using SendGrid

type SendOptions

type SendOptions struct {
	From        Recipient
	To          Recipient
	Title       string
	Content     string
	HTMLContent string
}

SendOptions are options used to define the message sent.

type Service

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

Service contains methods for sending emails

func New

func New(options Config) (*Service, error)

New returns a new service with the configured email provider

func (*Service) SendEmail

func (s *Service) SendEmail(ctx context.Context, options SendOptions) error

SendEmail to the specified receiver using the configured provider.

Jump to

Keyboard shortcuts

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