Documentation
¶
Index ¶
- func ExtractBouncedRecipient(email *Email) string
- func GetPrimaryConfirmationURL(urls ExtractedURLs, brokerDomain string) string
- func GetPrimaryFormURL(urls ExtractedURLs, brokerDomain string) string
- type ClassifiedResponse
- type Email
- type ExtractedURLs
- type Monitor
- func (m *Monitor) ArchiveEmails(uids []uint32, folder string) error
- func (m *Monitor) Connect(ctx context.Context) error
- func (m *Monitor) Disconnect() error
- func (m *Monitor) EnsureFolderExists(name string) error
- func (m *Monitor) FetchBounceEmails(ctx context.Context, days int) ([]Email, error)
- func (m *Monitor) FetchBrokerEmails(ctx context.Context, days int) ([]Email, error)
- func (m *Monitor) FetchBrokerEmailsFromFolder(ctx context.Context, folder string, days int) ([]Email, error)
- func (m *Monitor) WatchForNewEmails(ctx context.Context, callback func(Email)) error
- type ResponseType
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractBouncedRecipient ¶
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 ¶
ArchiveEmails moves multiple emails to the archive folder
func (*Monitor) Disconnect ¶
Disconnect closes the IMAP connection
func (*Monitor) EnsureFolderExists ¶
EnsureFolderExists creates a folder/label if it doesn't already exist
func (*Monitor) FetchBounceEmails ¶
FetchBounceEmails fetches emails that look like bounce/undeliverable notifications
func (*Monitor) FetchBrokerEmails ¶
FetchBrokerEmails fetches only emails from known broker domains
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