Documentation
¶
Overview ¶
Package mailtest runs in-process IMAP and SMTP servers over TLS for tests. Their certificates are self-signed, so clients must skip verification.
Index ¶
- func ServerTLSConfig(t testing.TB) *tls.Config
- type Delivery
- type IMAP
- func (s *IMAP) Append(t testing.TB, folder, raw string, flags ...imap.Flag) imap.UID
- func (s *IMAP) AppendAt(t testing.TB, folder, raw string, received time.Time, flags ...imap.Flag) imap.UID
- func (s *IMAP) CreateFolder(t testing.TB, name string, specialUse ...imap.MailboxAttr)
- func (s *IMAP) Flags(t testing.TB, folder string, uid imap.UID) []imap.Flag
- func (s *IMAP) HasFlag(t testing.TB, folder string, uid imap.UID, flag imap.Flag) bool
- func (s *IMAP) Subjects(t testing.TB, folder string) []string
- type IMAPOption
- type SMTP
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IMAP ¶
type IMAP struct {
Host string
Port string
Username string
Password string
// contains filtered or unexported fields
}
IMAP is an in-process IMAP server with one user.
func StartIMAP ¶
func StartIMAP(t testing.TB, options ...IMAPOption) *IMAP
StartIMAP starts a server with an empty INBOX. It stops when the test ends.
func (*IMAP) AppendAt ¶
func (s *IMAP) AppendAt(t testing.TB, folder, raw string, received time.Time, flags ...imap.Flag) imap.UID
AppendAt is Append with the time the server received the message.
func (*IMAP) CreateFolder ¶
CreateFolder creates a folder, optionally marked with a special-use attribute such as imap.MailboxAttrArchive.
func (*IMAP) Flags ¶
Flags returns the flags of the email with uid in folder, or nil when it is not there.
type IMAPOption ¶
type IMAPOption func(*imapConfig)
IMAPOption configures StartIMAP.
func WithSTARTTLS ¶
func WithSTARTTLS() IMAPOption
WithSTARTTLS serves plain connections that upgrade with STARTTLS.
type SMTP ¶
type SMTP struct {
Host string
Port string
Username string
Password string
// contains filtered or unexported fields
}
SMTP is an in-process SMTP server over implicit TLS that accepts AUTH LOGIN and AUTH PLAIN for one user and records delivered messages.
func (*SMTP) Deliveries ¶
Deliveries returns the messages accepted so far.