imapserver

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(redisAddr, imapAddr string, debugMode bool) error

ListenAndServe starts the IMAP server and listens for connections

Types

type Backend

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

Backend implements the go-imap backend interface

func NewBackend

func NewBackend(redisClient *redis.Client, debugMode bool) *Backend

NewBackend creates a new IMAP backend

func (*Backend) Login

func (b *Backend) Login(_ *imap.ConnInfo, username, password string) (backend.User, error)

Login authenticates a user. In this implementation, we accept any username/password

type Mailbox

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

Mailbox represents an IMAP mailbox (folder)

func (*Mailbox) Check

func (m *Mailbox) Check() error

Check checks the mailbox for updates

func (*Mailbox) CopyMessages

func (m *Mailbox) CopyMessages(uid bool, seqSet *imap.SeqSet, destName string) error

CopyMessages copies the specified messages to another mailbox

func (*Mailbox) CreateMessage

func (m *Mailbox) CreateMessage(flags []string, date time.Time, body imap.Literal) error

CreateMessage adds a new message to the mailbox

func (*Mailbox) Expunge

func (m *Mailbox) Expunge() error

Expunge permanently removes messages marked for deletion

func (*Mailbox) Info

func (m *Mailbox) Info() (*imap.MailboxInfo, error)

Info returns information about the mailbox

func (*Mailbox) ListMessages

func (m *Mailbox) ListMessages(uid bool, seqSet *imap.SeqSet, items []imap.FetchItem, ch chan<- *imap.Message) error

ListMessages returns a list of messages

func (*Mailbox) MoveMessages

func (m *Mailbox) MoveMessages(uid bool, seqSet *imap.SeqSet, destName string) error

MoveMessages moves the specified messages to another mailbox

func (*Mailbox) Name

func (m *Mailbox) Name() string

Name returns the mailbox name

func (*Mailbox) SearchMessages

func (m *Mailbox) SearchMessages(uid bool, criteria *imap.SearchCriteria) ([]uint32, error)

SearchMessages searches for messages matching the given criteria

func (*Mailbox) SetSubscribed

func (m *Mailbox) SetSubscribed(subscribed bool) error

SetSubscribed sets the mailbox subscription status

func (*Mailbox) Status

func (m *Mailbox) Status(items []imap.StatusItem) (*imap.MailboxStatus, error)

Status returns the mailbox status

func (*Mailbox) UpdateMessagesFlags

func (m *Mailbox) UpdateMessagesFlags(uid bool, seqSet *imap.SeqSet, operation imap.FlagsOp, flags []string) error

UpdateMessagesFlags updates flags for the specified messages

type Message

type Message struct {
	Email *mail.Email
	Uid   uint32
	Flags []string
	Key   string // Redis key where this message is stored
}

Message represents an email message

func (*Message) Fetch

func (m *Message) Fetch(seqNum uint32, items []imap.FetchItem) (*imap.Message, error)

Fetch converts a Message to an imap.Message

func (*Message) Match

func (m *Message) Match(seqNum uint32, criteria *imap.SearchCriteria) bool

Match checks if the message matches the search criteria

type Server

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

Server represents an IMAP server

func NewServer

func NewServer(redisClient *redis.Client, addr string, debugMode bool) *Server

NewServer creates a new IMAP server

func (*Server) Close

func (s *Server) Close() error

Close stops the IMAP server

func (*Server) Start

func (s *Server) Start() error

Start starts the IMAP server

func (*Server) StartTLS

func (s *Server) StartTLS(certFile, keyFile string) error

StartTLS starts the IMAP server with TLS Note: This is not implemented correctly yet

type User

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

User represents a user connected to the IMAP server

func (*User) CreateMailbox

func (u *User) CreateMailbox(name string) error

CreateMailbox creates a new mailbox

func (*User) DeleteMailbox

func (u *User) DeleteMailbox(name string) error

DeleteMailbox deletes a mailbox

func (*User) GetMailbox

func (u *User) GetMailbox(name string) (backend.Mailbox, error)

GetMailbox returns a mailbox by name

func (*User) ListMailboxes

func (u *User) ListMailboxes(subscribed bool) ([]backend.Mailbox, error)

ListMailboxes returns a list of mailboxes available for this user

func (*User) Logout

func (u *User) Logout() error

Logout is called when a user logs out

func (*User) RenameMailbox

func (u *User) RenameMailbox(existingName, newName string) error

RenameMailbox renames a mailbox

func (*User) Username

func (u *User) Username() string

Username returns the user's username

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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