mailqueue

package
v0.10.0-wip Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mailqueue provides email queue storage and management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildEmailMessage

func BuildEmailMessage(from, to, subject, body string) []byte

BuildEmailMessage automatically detects content type and builds appropriate email message.

func BuildEmailMessageWithHeaders

func BuildEmailMessageWithHeaders(from, to, subject, body string, headers map[string]string) []byte

BuildEmailMessageWithHeaders builds an email message with optional headers for threading.

func BuildEmailMessageWithThreading

func BuildEmailMessageWithThreading(from, to, subject, body, domain string, inReplyTo, references string) []byte

BuildEmailMessageWithThreading builds an email message with threading headers.

func BuildHTMLEmailMessage

func BuildHTMLEmailMessage(from, to, subject, htmlBody string) []byte

BuildHTMLEmailMessage constructs a properly formatted HTML email message.

func BuildTextEmailMessage

func BuildTextEmailMessage(from, to, subject, textBody string) []byte

BuildTextEmailMessage constructs a properly formatted plain text email message.

func ExtractMessageIDFromRawMessage

func ExtractMessageIDFromRawMessage(rawMessage []byte) string

ExtractMessageIDFromRawMessage extracts the Message-ID header from a raw email message.

func GenerateMessageID

func GenerateMessageID(domain string) string

GenerateMessageID creates a unique Message-ID header for email threading.

Types

type MailQueueItem

type MailQueueItem struct {
	ID                int64
	InsertFingerprint *string
	ArticleID         *int64
	Attempts          int
	Sender            *string
	Recipient         string
	RawMessage        []byte
	DueTime           *time.Time
	LastSMTPCode      *int
	LastSMTPMessage   *string
	CreateTime        time.Time
}

MailQueueItem represents an email in the queue.

type MailQueueRepository

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

MailQueueRepository handles database operations for the mail queue.

func NewMailQueueRepository

func NewMailQueueRepository(db *sql.DB) *MailQueueRepository

NewMailQueueRepository creates a new mail queue repository.

func (*MailQueueRepository) Delete

func (r *MailQueueRepository) Delete(ctx context.Context, id int64) error

Delete removes a successfully sent email from the queue.

func (*MailQueueRepository) GetFailed

func (r *MailQueueRepository) GetFailed(ctx context.Context, maxAttempts int, limit int) ([]*MailQueueItem, error)

GetFailed retrieves emails that have exceeded max attempts.

func (*MailQueueRepository) GetPending

func (r *MailQueueRepository) GetPending(ctx context.Context, limit int) ([]*MailQueueItem, error)

GetPending retrieves emails that are ready to be sent (due_time is null or past).

func (*MailQueueRepository) Insert

func (r *MailQueueRepository) Insert(ctx context.Context, item *MailQueueItem) error

Insert adds a new email to the queue.

func (*MailQueueRepository) UpdateAttempts

func (r *MailQueueRepository) UpdateAttempts(ctx context.Context, id int64, smtpCode *int, smtpMessage *string, nextDueTime *time.Time) error

UpdateAttempts increments the attempt count and sets the next due time.

Jump to

Keyboard shortcuts

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