Documentation
¶
Index ¶
- func Send(req Request, cfg config.Config) error
- type MockSMTPClient
- func (m *MockSMTPClient) Auth(auth smtp.Auth) error
- func (m *MockSMTPClient) Close() error
- func (m *MockSMTPClient) Data() (io.WriteCloser, error)
- func (m *MockSMTPClient) Dial(addr string) (SMTPClient, error)
- func (m *MockSMTPClient) Mail(from string) error
- func (m *MockSMTPClient) Quit() error
- func (m *MockSMTPClient) Rcpt(to string) error
- type MockWriteCloser
- type Request
- type SMTPClient
- type SMTPDialer
- type Service
- type ServiceImpl
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MockSMTPClient ¶
type MockSMTPClient struct { DialFunc func(addr string) (SMTPClient, error) MailFunc func(from string) error RcptFunc func(to string) error DataFunc func() (io.WriteCloser, error) QuitFunc func() error CloseFunc func() error AuthFunc func(auth smtp.Auth) error }
MockSMTPClient implements a mock SMTP client for testing
func (*MockSMTPClient) Auth ¶
func (m *MockSMTPClient) Auth(auth smtp.Auth) error
Auth is a mock implementation of smtp.Client.Auth
func (*MockSMTPClient) Close ¶
func (m *MockSMTPClient) Close() error
Close is a mock implementation of smtp.Client.Close
func (*MockSMTPClient) Data ¶
func (m *MockSMTPClient) Data() (io.WriteCloser, error)
Data is a mock implementation of smtp.Client.Data
func (*MockSMTPClient) Dial ¶
func (m *MockSMTPClient) Dial(addr string) (SMTPClient, error)
Dial is a mock implementation of net/smtp.Dial
func (*MockSMTPClient) Mail ¶
func (m *MockSMTPClient) Mail(from string) error
Mail is a mock implementation of smtp.Client.Mail
func (*MockSMTPClient) Quit ¶
func (m *MockSMTPClient) Quit() error
Quit is a mock implementation of smtp.Client.Quit
func (*MockSMTPClient) Rcpt ¶
func (m *MockSMTPClient) Rcpt(to string) error
Rcpt is a mock implementation of smtp.Client.Rcpt
type MockWriteCloser ¶
type MockWriteCloser struct { WriteFunc func(p []byte) (n int, err error) CloseFunc func() error Data []byte }
MockWriteCloser implements a mock for io.WriteCloser
func (*MockWriteCloser) Close ¶
func (m *MockWriteCloser) Close() error
Close is a mock implementation of io.Closer.Close
type Request ¶
type Request struct { From string `json:"from"` To string `json:"to"` Subject string `json:"subject"` Body string `json:"body"` HTML bool `json:"html"` }
Request represents an incoming request to send an email
type SMTPClient ¶
type SMTPClient interface { Mail(from string) error Rcpt(to string) error Data() (io.WriteCloser, error) Quit() error Close() error Auth(auth smtp.Auth) error }
SMTPClient defines the interface for SMTP operations This allows us to mock the SMTP client for testing
type SMTPDialer ¶
type SMTPDialer func(addr string) (SMTPClient, error)
SMTPDialer is a function type for creating SMTP clients
var DefaultSMTPDialer SMTPDialer = defaultSMTPDialFn
DefaultSMTPDialer is the default dialer that can be replaced for testing
type ServiceImpl ¶
type ServiceImpl struct {
// contains filtered or unexported fields
}
ServiceImpl implements the Service interface
func NewService ¶
func NewService(dialer SMTPDialer) *ServiceImpl
NewService creates a new email service with the given SMTP dialer