message

package
v0.0.0-...-30e5c69 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package message contains message handling logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delivery

type Delivery struct {
	Meta   Metadata
	Reader io.Reader
}

Delivery is used to add a message to storage.

func (*Delivery) Date

func (d *Delivery) Date() time.Time

Date getter.

func (*Delivery) From

func (d *Delivery) From() *mail.Address

From getter.

func (*Delivery) ID

func (d *Delivery) ID() string

ID getter.

func (*Delivery) Mailbox

func (d *Delivery) Mailbox() string

Mailbox getter.

func (*Delivery) Seen

func (d *Delivery) Seen() bool

Seen getter.

func (*Delivery) Size

func (d *Delivery) Size() int64

Size getter.

func (*Delivery) Source

func (d *Delivery) Source() (io.ReadCloser, error)

Source contains the raw content of the message.

func (*Delivery) Subject

func (d *Delivery) Subject() string

Subject getter.

func (*Delivery) To

func (d *Delivery) To() []*mail.Address

To getter.

type Manager

type Manager interface {
	Deliver(
		to *policy.Recipient,
		from string,
		recipients []*policy.Recipient,
		prefix string,
		content []byte,
	) (id string, err error)
	GetMetadata(mailbox string) ([]*Metadata, error)
	GetMessage(mailbox, id string) (*Message, error)
	MarkSeen(mailbox, id string) error
	PurgeMessages(mailbox string) error
	RemoveMessage(mailbox, id string) error
	SourceReader(mailbox, id string) (io.ReadCloser, error)
	MailboxForAddress(address string) (string, error)
	//mailbox
	AddAllowedMailbox(string) error
	RemoveAllowedMailbox(string) error
	KeepaliveAllowedMailbox(string) error
	IsMailboxAllow(string string, duration time.Duration) bool
	CleanupExpiredMailbox(period time.Duration) int
	//mailhost
	AddAllowedMailhost(host string, weight int) error
	RemoveAllowedMailhost(id string) error
	UpdateMailhost(id string, host string, weight int) error
	ListMailhost() []storage.Mailhost
}

Manager is the interface controllers use to interact with messages.

type Message

type Message struct {
	Metadata
	// contains filtered or unexported fields
}

Message holds both the metadata and content of a message.

func New

func New(m Metadata, e *enmime.Envelope) *Message

New constructs a new Message

func (*Message) Attachments

func (m *Message) Attachments() []*enmime.Part

Attachments returns the MIME attachments for the message.

func (*Message) HTML

func (m *Message) HTML() string

HTML returns the HTML body of the message.

func (*Message) Header

func (m *Message) Header() textproto.MIMEHeader

Header returns the header map for this message.

func (*Message) MIMEErrors

func (m *Message) MIMEErrors() []*enmime.Error

MIMEErrors returns MIME parsing errors and warnings.

func (*Message) Text

func (m *Message) Text() string

Text returns the plain text body of the message.

type Metadata

type Metadata struct {
	Mailbox string
	ID      string
	From    *mail.Address
	To      []*mail.Address
	Date    time.Time
	Subject string
	Size    int64
	Seen    bool
}

Metadata holds information about a message, but not the content.

type StoreManager

type StoreManager struct {
	AddrPolicy *policy.Addressing
	Store      storage.Store
	Hub        *msghub.Hub
}

StoreManager is a message Manager backed by the storage.Store.

func (*StoreManager) AddAllowedMailbox

func (s *StoreManager) AddAllowedMailbox(mailbox string) error

func (*StoreManager) AddAllowedMailhost

func (s *StoreManager) AddAllowedMailhost(host string, weight int) error

mailhost

func (*StoreManager) CleanupExpiredMailbox

func (s *StoreManager) CleanupExpiredMailbox(period time.Duration) int

func (*StoreManager) Deliver

func (s *StoreManager) Deliver(
	to *policy.Recipient,
	from string,
	recipients []*policy.Recipient,
	prefix string,
	source []byte,
) (string, error)

Deliver submits a new message to the store.

func (*StoreManager) GetMessage

func (s *StoreManager) GetMessage(mailbox, id string) (*Message, error)

GetMessage returns the specified message.

func (*StoreManager) GetMetadata

func (s *StoreManager) GetMetadata(mailbox string) ([]*Metadata, error)

GetMetadata returns a slice of metadata for the specified mailbox.

func (*StoreManager) IsMailboxAllow

func (s *StoreManager) IsMailboxAllow(mailbox string, td time.Duration) bool

func (*StoreManager) KeepaliveAllowedMailbox

func (s *StoreManager) KeepaliveAllowedMailbox(mailbox string) error

func (*StoreManager) ListMailhost

func (s *StoreManager) ListMailhost() []storage.Mailhost

func (*StoreManager) MailboxForAddress

func (s *StoreManager) MailboxForAddress(mailbox string) (string, error)

MailboxForAddress parses an email address to return the canonical mailbox name.

func (*StoreManager) MarkSeen

func (s *StoreManager) MarkSeen(mailbox, id string) error

MarkSeen marks the message as having been read.

func (*StoreManager) PurgeMessages

func (s *StoreManager) PurgeMessages(mailbox string) error

PurgeMessages removes all messages from the specified mailbox.

func (*StoreManager) RemoveAllowedMailbox

func (s *StoreManager) RemoveAllowedMailbox(mailbox string) error

func (*StoreManager) RemoveAllowedMailhost

func (s *StoreManager) RemoveAllowedMailhost(id string) error

func (*StoreManager) RemoveMessage

func (s *StoreManager) RemoveMessage(mailbox, id string) error

RemoveMessage deletes the specified message.

func (*StoreManager) SourceReader

func (s *StoreManager) SourceReader(mailbox, id string) (io.ReadCloser, error)

SourceReader allows the stored message source to be read.

func (*StoreManager) UpdateMailhost

func (s *StoreManager) UpdateMailhost(id string, host string, weight int) error

Jump to

Keyboard shortcuts

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