Documentation
¶
Index ¶
- Variables
- func ConvertToIMAPMessage(entity *message.Entity) *imap.Message
- func ExtractRecipients(headers *mail.Header) []string
- func GenerateMessageID(domain string) string
- func IsSignatureValid(header *mail.Header, body []byte) bool
- func IsTransportEnvelope(msg *message.Entity) bool
- func LoadSMIMECredentials(certPath, keyPath string) (*x509.Certificate, interface{}, error)
- func ParseEmailFromSession(s Session) (*mail.Header, []byte, error)
- func ParseEmailMessage(rawMessage []byte) (*mail.Reader, error)
- func StartIMAPWithSTARTTLS(addr string, backend *IMAPBackend) error
- func StartIMAPWithTLS(addr string, backend *IMAPBackend) error
- func StartSMTP(addr string, domain string, backend *Backend) error
- type Backend
- type Config
- type IMAPBackend
- type IMAPMailbox
- func (m *IMAPMailbox) Check() error
- func (m *IMAPMailbox) CopyMessages(uid bool, seqSet *imap.SeqSet, destName string) error
- func (m *IMAPMailbox) CreateMessage(flags []string, date time.Time, body imap.Literal) error
- func (m *IMAPMailbox) Expunge() error
- func (m *IMAPMailbox) Info() (*imap.MailboxInfo, error)
- func (m *IMAPMailbox) ListMessages(uid bool, seqSet *imap.SeqSet, items []imap.FetchItem, ch chan<- *imap.Message) error
- func (m *IMAPMailbox) ListenUpdates() <-chan backend.Update
- func (m *IMAPMailbox) Name() string
- func (m *IMAPMailbox) NotifyUpdate()
- func (m *IMAPMailbox) SearchMessages(uid bool, criteria *imap.SearchCriteria) ([]uint32, error)
- func (m *IMAPMailbox) SetSubscribed(subscribed bool) error
- func (m *IMAPMailbox) Status(items []imap.StatusItem) (*imap.MailboxStatus, error)
- func (m *IMAPMailbox) StopListenUpdates(ch <-chan backend.Update)
- func (m *IMAPMailbox) UpdateMessagesFlags(uid bool, seqSet *imap.SeqSet, operation imap.FlagsOp, flags []string) error
- type IMAPUser
- func (u *IMAPUser) CreateMailbox(name string) error
- func (u *IMAPUser) DeleteMailbox(name string) error
- func (u *IMAPUser) GetMailbox(name string) (backend.Mailbox, error)
- func (u *IMAPUser) ListMailboxes(subscribed bool) ([]backend.Mailbox, error)
- func (u *IMAPUser) Logout() error
- func (u *IMAPUser) RenameMailbox(existingName, newName string) error
- func (u *IMAPUser) Username() string
- type Session
- func (s *Session) Auth(mech string) (sasl.Server, error)
- func (s *Session) AuthMechanisms() []string
- func (s *Session) Data(r io.Reader) error
- func (s *Session) GetData() ([]byte, error)
- func (s *Session) GetFrom() (string, error)
- func (s *Session) GetHandler() func(*Session) error
- func (s *Session) GetSigner() *Signer
- func (s *Session) GetStore() pec_storage.MessageStore
- func (s *Session) GetTo() ([]string, error)
- func (s *Session) Logout() error
- func (s *Session) Mail(from string, opts *smtp.MailOptions) error
- func (s *Session) Rcpt(to string, opts *smtp.RcptOptions) error
- func (s *Session) Reset()
- type Signer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMailboxNotAllowed is returned when a mailbox operation is not allowed ErrMailboxNotAllowed = errors.New("mailbox operation not allowed") // ErrNotAllowed is returned when an operation is not allowed ErrNotAllowed = errors.New("operation not allowed") )
Functions ¶
func ConvertToIMAPMessage ¶
Helper function to convert message.Entity to imap.Message
func ExtractRecipients ¶
ExtractRecipients extracts and cleans recipient addresses from To and Cc headers
func GenerateMessageID ¶
generateMessageID generates a unique message ID
func IsSignatureValid ¶
IsSignatureValid checks if the S/MIME signature of the message is valid. It writes the body to a temporary file and calls verifySMIMEWithOpenSSL.
func IsTransportEnvelope ¶
IsTransportEnvelope checks if the message is a PEC transport envelope
func LoadSMIMECredentials ¶
func LoadSMIMECredentials(certPath, keyPath string) (*x509.Certificate, interface{}, error)
func ParseEmailMessage ¶
ParseEmailMessage parses a raw email message and returns a *mail.Reader.
func StartIMAPWithSTARTTLS ¶
func StartIMAPWithSTARTTLS(addr string, backend *IMAPBackend) error
Modify your existing StartIMAP function to clarify it uses STARTTLS
func StartIMAPWithTLS ¶
func StartIMAPWithTLS(addr string, backend *IMAPBackend) error
Add this new function to support direct TLS connections
Types ¶
type Backend ¶
type Backend struct {
// contains filtered or unexported fields
}
The Backend implements SMTP server methods.
func NewBackend ¶
func NewBackend(signer *Signer, store pec_storage.MessageStore, handler func(*Session) error, domain string) *Backend
type Config ¶
type Config struct {
Domain string `json:"domain"`
SMTPServer string `json:"smtp_server"`
IMAPServer string `json:"imap_server"`
CertFile string `json:"cert_file"`
KeyFile string `json:"key_file"`
APIServer string `json:"api_server"`
}
func LoadConfig ¶
type IMAPBackend ¶
type IMAPBackend struct {
// contains filtered or unexported fields
}
IMAPBackend implements the IMAP server backend
func NewIMAPBackend ¶
func NewIMAPBackend(store pec_storage.MessageStore, cert *x509.Certificate, key interface{}) *IMAPBackend
type IMAPMailbox ¶
type IMAPMailbox struct {
// contains filtered or unexported fields
}
IMAPMailbox represents a mailbox (folder)
func (*IMAPMailbox) Check ¶
func (m *IMAPMailbox) Check() error
func (*IMAPMailbox) CopyMessages ¶
func (*IMAPMailbox) CreateMessage ¶
func (*IMAPMailbox) Expunge ¶
func (m *IMAPMailbox) Expunge() error
func (*IMAPMailbox) Info ¶
func (m *IMAPMailbox) Info() (*imap.MailboxInfo, error)
func (*IMAPMailbox) ListMessages ¶
func (*IMAPMailbox) ListenUpdates ¶
func (m *IMAPMailbox) ListenUpdates() <-chan backend.Update
Implement ListenUpdates for IDLE support
func (*IMAPMailbox) Name ¶
func (m *IMAPMailbox) Name() string
func (*IMAPMailbox) NotifyUpdate ¶
func (m *IMAPMailbox) NotifyUpdate()
Add NotifyUpdate to trigger notifications
func (*IMAPMailbox) SearchMessages ¶
func (m *IMAPMailbox) SearchMessages(uid bool, criteria *imap.SearchCriteria) ([]uint32, error)
func (*IMAPMailbox) SetSubscribed ¶
func (m *IMAPMailbox) SetSubscribed(subscribed bool) error
func (*IMAPMailbox) Status ¶
func (m *IMAPMailbox) Status(items []imap.StatusItem) (*imap.MailboxStatus, error)
func (*IMAPMailbox) StopListenUpdates ¶
func (m *IMAPMailbox) StopListenUpdates(ch <-chan backend.Update)
Implement StopListeningUpdates to clean up
func (*IMAPMailbox) UpdateMessagesFlags ¶
type IMAPUser ¶
type IMAPUser struct {
// contains filtered or unexported fields
}
IMAPUser represents an authenticated user
func (*IMAPUser) CreateMailbox ¶
CreateMailbox creates a new mailbox
func (*IMAPUser) DeleteMailbox ¶
func (*IMAPUser) ListMailboxes ¶
func (*IMAPUser) RenameMailbox ¶
type Session ¶
type Session struct {
From string
To []string
Store pec_storage.MessageStore
Domain string
// contains filtered or unexported fields
}
A Session is returned after successful login.
func (*Session) AuthMechanisms ¶
AuthMechanisms returns a slice of available auth mechanisms; only PLAIN is supported in this example.
func (*Session) GetHandler ¶
func (*Session) GetStore ¶
func (s *Session) GetStore() pec_storage.MessageStore
type Signer ¶
type Signer struct {
Cert *x509.Certificate
Key interface{}
Domain string
}
Use your existing Signer struct
func (*Signer) CreateSignedMimeMessage ¶
Create a complete S/MIME signed email message from email bytes