email

package
v0.8.0-beta Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package email provides functionality for an email inbox with multiple SMTP servers and IMAP clients.

Index

Constants

View Source
const (
	ChannelEmail = "email"
)

Variables

This section is empty.

Functions

func NewSmtpPool

func NewSmtpPool(configs []SMTPConfig) ([]*smtppool.Pool, error)

NewSmtpPool returns a smtppool

Types

type Config

type Config struct {
	SMTP []SMTPConfig `json:"smtp"`
	IMAP []IMAPConfig `json:"imap"`
	From string       `json:"from"`
}

Config holds the email inbox configuration with multiple SMTP servers and IMAP clients.

type Email

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

Email represents the email inbox with multiple SMTP servers and IMAP clients.

func New

func New(store inbox.MessageStore, userStore inbox.UserStore, opts Opts) (*Email, error)

New returns a new instance of the email inbox.

func (*Email) Channel

func (e *Email) Channel() string

Channel returns the channel name for this inbox.

func (*Email) Close

func (e *Email) Close() error

Close cloes email channel by closing the smtp pool

func (*Email) FromAddress

func (e *Email) FromAddress() string

FromAddress returns the from address for this inbox.

func (*Email) Identifier

func (e *Email) Identifier() int

Identifier returns the unique identifier of the inbox which is the database ID.

func (*Email) ReadIncomingMessages

func (e *Email) ReadIncomingMessages(ctx context.Context, cfg IMAPConfig) error

ReadIncomingMessages reads and processes incoming messages from an IMAP server based on the provided configuration.

func (*Email) Receive

func (e *Email) Receive(ctx context.Context) error

Receive starts reading incoming messages for each IMAP client.

func (*Email) Send

func (e *Email) Send(m models.Message) error

Send sends an email using one of the configured SMTP servers.

type IMAPConfig

type IMAPConfig struct {
	Host           string `json:"host"`
	Port           int    `json:"port"`
	Username       string `json:"username"`
	Password       string `json:"password"`
	Mailbox        string `json:"mailbox"`
	ReadInterval   string `json:"read_interval"`
	ScanInboxSince string `json:"scan_inbox_since"`
	TLSType        string `json:"tls_type"`
	TLSSkipVerify  bool   `json:"tls_skip_verify"`
}

IMAPConfig holds IMAP client credentials and configuration.

type Opts

type Opts struct {
	ID      int
	Headers map[string]string
	Config  Config
	Lo      *logf.Logger
}

Opts holds the options required for the email inbox.

type SMTPConfig

type SMTPConfig struct {
	Username      string            `json:"username"`
	Password      string            `json:"password"`
	AuthProtocol  string            `json:"auth_protocol"`
	TLSType       string            `json:"tls_type"`
	TLSSkipVerify bool              `json:"tls_skip_verify"`
	EmailHeaders  map[string]string `json:"email_headers"`
	smtppool.Opt  `json:",squash"`  // SMTP pool options.
}

SMTPConfig represents an SMTP server's credentials with the smtppool options.

Jump to

Keyboard shortcuts

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