inbox

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 15 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractBouncedRecipient

func ExtractBouncedRecipient(email *Email) string

ExtractBouncedRecipient extracts the email address that bounced from an NDR email

func GetPrimaryConfirmationURL

func GetPrimaryConfirmationURL(urls ExtractedURLs, brokerDomain string) string

GetPrimaryConfirmationURL returns the most likely confirmation URL

func GetPrimaryFormURL

func GetPrimaryFormURL(urls ExtractedURLs, brokerDomain string) string

GetPrimaryFormURL returns the most likely opt-out form URL using scoring

Types

type ClassifiedResponse

type ClassifiedResponse struct {
	Email            *Email
	Type             ResponseType
	URLs             ExtractedURLs
	FormURL          string // Primary form URL (if form_required)
	ConfirmURL       string // Primary confirmation URL (if confirmation_required)
	BouncedRecipient string // Email address that bounced (if bounced)
	Confidence       float64
	Reason           string // Human-readable reason for classification
	NeedsReview      bool   // Whether manual review is recommended
}

ClassifiedResponse represents a classified email response

func ClassifyResponse

func ClassifyResponse(email *Email) ClassifiedResponse

ClassifyResponse analyzes an email and determines the response type

type Email

type Email struct {
	UID        uint32 // IMAP UID for operations like move/delete
	MessageID  string
	From       string
	FromName   string // Sender display name (e.g., "Mail Delivery System")
	FromDomain string
	Subject    string
	Body       string
	HTMLBody   string
	ReceivedAt time.Time
	BrokerID   string // Matched broker ID (if found)
	BrokerName string // Matched broker name (if found)
}

Email represents a parsed email from a broker

type ExtractedURLs

type ExtractedURLs struct {
	FormURLs         []string // URLs that look like opt-out forms
	ConfirmationURLs []string // URLs that look like confirmation links
	UnsubscribeURLs  []string // Unsubscribe links
	AllURLs          []string // All URLs found
}

ExtractedURLs contains categorized URLs from an email

func ParseEmailURLs

func ParseEmailURLs(email *Email) ExtractedURLs

ParseEmailURLs extracts and categorizes URLs from an email

type Monitor

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

Monitor handles IMAP connection and email monitoring

func NewMonitor

func NewMonitor(cfg config.InboxConfig, brokerList []broker.Broker) *Monitor

NewMonitor creates a new inbox monitor

func (*Monitor) ArchiveEmails

func (m *Monitor) ArchiveEmails(uids []uint32, folder string) error

ArchiveEmails moves multiple emails to the archive folder

func (*Monitor) Connect

func (m *Monitor) Connect(ctx context.Context) error

Connect establishes IMAP connection

func (*Monitor) Disconnect

func (m *Monitor) Disconnect() error

Disconnect closes the IMAP connection

func (*Monitor) EnsureFolderExists

func (m *Monitor) EnsureFolderExists(name string) error

EnsureFolderExists creates a folder/label if it doesn't already exist

func (*Monitor) FetchBounceEmails

func (m *Monitor) FetchBounceEmails(ctx context.Context, days int) ([]Email, error)

FetchBounceEmails fetches emails that look like bounce/undeliverable notifications

func (*Monitor) FetchBrokerEmails

func (m *Monitor) FetchBrokerEmails(ctx context.Context, days int) ([]Email, error)

FetchBrokerEmails fetches only emails from known broker domains

func (*Monitor) FetchBrokerEmailsFromFolder

func (m *Monitor) FetchBrokerEmailsFromFolder(ctx context.Context, folder string, days int) ([]Email, error)

FetchBrokerEmailsFromFolder fetches broker emails from a specific folder

func (*Monitor) FetchRecentEmails

func (m *Monitor) FetchRecentEmails(ctx context.Context, days int) ([]Email, error)

FetchRecentEmails fetches emails from the last N days

func (*Monitor) WatchForNewEmails

func (m *Monitor) WatchForNewEmails(ctx context.Context, callback func(Email)) error

WatchForNewEmails monitors for new emails (blocking)

type ResponseType

type ResponseType string

ResponseType represents the type of broker response

const (
	ResponseFormRequired         ResponseType = "form_required"         // Need to fill out a form
	ResponseConfirmationRequired ResponseType = "confirmation_required" // Need to click confirmation link
	ResponseSuccess              ResponseType = "success"               // Removal confirmed/completed
	ResponseRejected             ResponseType = "rejected"              // Request denied
	ResponsePending              ResponseType = "pending"               // Processing, will follow up
	ResponseBounced              ResponseType = "bounced"               // Email bounced - invalid address
	ResponseUnknown              ResponseType = "unknown"               // Needs manual review
)

func ClassifyBySubjectOnly

func ClassifyBySubjectOnly(subject string) (ResponseType, float64, bool)

ClassifyBySubjectOnly classifies based on subject line only (for reclassifying database records) Returns the response type, confidence, and whether it needs review

type Summary

type Summary struct {
	Total           int
	Success         int
	FormRequired    int
	ConfirmRequired int
	Rejected        int
	Pending         int
	Bounced         int
	Unknown         int
	NeedReview      int
}

Summary provides a summary of classified responses

func SummarizeResponses

func SummarizeResponses(responses []ClassifiedResponse) Summary

SummarizeResponses generates a summary of classified responses

Jump to

Keyboard shortcuts

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