Help us shape the future of Go! Take the 2026 Go Developer Survey

imap

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Filename string
	Data     []byte
}

Attachment represents an email attachment

func CollectAttachments

func CollectAttachments(log *zerolog.Logger, r io.Reader) []Attachment

CollectAttachments walks a raw MIME message and returns the DMARC report attachments in it. It is exported for the Maildir intake, which holds whole messages on disk instead of an IMAP body.

type Client

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

Client represents an IMAP client

func NewClient

func NewClient(cfg *config.IMAPConfig, log *zerolog.Logger) *Client

NewClient creates a new IMAP client

func (*Client) Connect

func (c *Client) Connect() error

Connect establishes connection to IMAP server

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect closes the IMAP connection

func (*Client) FetchDMARCReports

func (c *Client) FetchDMARCReports() (*FetchResult, error)

FetchDMARCReports fetches DMARC reports from the mailbox

func (*Client) MarkAsSeen

func (c *Client) MarkAsSeen(messageIDs []uint32) error

MarkAsSeen marks messages as seen

func (*Client) MoveMessages

func (c *Client) MoveMessages(messageIDs []uint32, destMailbox string) error

MoveMessages moves messages to a destination mailbox using COPY + DELETE + EXPUNGE

type FetchResult

type FetchResult struct {
	Reports    []Report
	MessageIDs []uint32
	// DeadletterIDs are the messages of the batch that carried no report at
	// all. The Maildir intake moves them to the deadletter mailbox instead of
	// cur/, so they are not fetched again as if nothing happened.
	DeadletterIDs []uint32
}

FetchResult holds the fetched reports and the message sequence numbers

type Report

type Report struct {
	Subject string
	From    string
	Date    string
	// MessageID is the RFC 5322 Message-ID from the IMAP envelope: the one
	// key that finds the mail again on any server (SEARCH HEADER
	// Message-ID, doveadm search, Gmail's rfc822msgid:) and in the MTA log.
	MessageID string
	// UID is the message's IMAP UID in the fetched mailbox. It is only
	// stable there: a move to the processed mailbox assigns a new one.
	UID         uint32
	Attachments []Attachment
}

Report represents a DMARC report email

Jump to

Keyboard shortcuts

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