Documentation ¶
Index ¶
Constants ¶
const ( // BeforeSend is the Hook that's called before a mail is sent. BeforeSend = Hook(iota + 1) // AfterSend is the Hook that's called after a mail has been sent. AfterSend )
Variables ¶
var ( // ErrNoTransport means no transport is configured. ErrNoTransport = errors.New("no transport") // ErrUnconfiguredTransport means a transport with a specific name is not configured. ErrUnconfiguredTransport = errors.New("unconfigured transport") )
Functions ¶
Types ¶
type Dog ¶ added in v0.8.0
type Dog struct {
// contains filtered or unexported fields
}
A Dog can send mails through one of multiple configured transports.
func (*Dog) Send ¶ added in v0.8.0
Send sends the given mail through the default transport.
A different transport can be specified with the Use() option:
dog.Send(context.TODO(), m, postdog.Use("transport-name"))
If the Use() option is used and no transport with the specified name has been registered, Send() will return ErrUnconfiguredTransport.
If the Use() option is not used, the default transport will be used instead. The default transport is automatically the first transport that has been registered and can be overriden by calling dog.Use("transport-name"). If there's no default transport available, Send() will return ErrNoTransport.
func (*Dog) SendConfig ¶ added in v0.9.2
SendConfig does the same as Send() but accepts a send.Config instead of send.Options.
type ListenerFunc ¶ added in v0.8.0
ListenerFunc allows functions to be used as Listeners.
type Mail ¶ added in v0.8.0
type Mail interface { // From returns the sender of the mail. From() mail.Address // Recipients returns the recipients of the mail. Recipients() []mail.Address // RFC returns the RFC 5322 body / data of the mail. RFC() string }
A Mail provides the sender, recipients and the mail body as defined in RFC 5322.
func ApplyMiddleware ¶ added in v0.12.2
ApplyMiddleware applies the Middleware mw on the Mail m.
type Middleware ¶
Middleware is called on every Send(), allowing manipulation of mails before they are passed to the Transport.
type MiddlewareFunc ¶
A MiddlewareFunc allows functions to be used as Middleware.
func (MiddlewareFunc) Handle ¶
func (mw MiddlewareFunc) Handle(ctx context.Context, m Mail, fn NextMiddleware) (Mail, error)
Handle calls mw() with the given arguments.
type NextMiddleware ¶ added in v0.10.1
NextMiddleware wraps the next function that Middlewares receive as the last parameter.
type OptionFunc ¶ added in v0.8.0
type OptionFunc func(*Dog)
OptionFunc allows functions to be used as Options.
func WithHook ¶ added in v0.8.0
func WithHook(h Hook, l Listener) OptionFunc
WithHook returns an OptionFunc that adds Listener l for Hook h to a *Dog.
func WithMiddleware ¶
func WithMiddleware(mws ...Middleware) OptionFunc
WithMiddleware returns an OptionFunc that adds the middleware mws to a *Dog.
func WithMiddlewareFunc ¶ added in v0.8.0
func WithMiddlewareFunc(mws ...MiddlewareFunc) OptionFunc
WithMiddlewareFunc returns an OptionFunc that adds the middleware mws to a *Dog.
func WithRateLimiter ¶ added in v0.8.0
func WithRateLimiter(rl Waiter) OptionFunc
WithRateLimiter returns an OptionFunc that adds a middleware to a *Dog.
The middleware will call rl.Wait() for every mail that's sent.
func WithTransport ¶ added in v0.8.0
func WithTransport(name string, tr Transport) OptionFunc
WithTransport returns an OptionFunc that adds the transport tr with the name in name to a *Dog.
Directories ¶
Path | Synopsis |
---|---|
mocks
Package mock_config is a generated GoMock package.
|
Package mock_config is a generated GoMock package. |
internal
|
|
rfc/mocks
Package mock_rfc is a generated GoMock package.
|
Package mock_rfc is a generated GoMock package. |
Package mock_postdog is a generated GoMock package.
|
Package mock_postdog is a generated GoMock package. |
plugin
|
|
archive/mocks
Package mock_archive is a generated GoMock package.
|
Package mock_archive is a generated GoMock package. |
mocks
Package mock_queue is a generated GoMock package.
|
Package mock_queue is a generated GoMock package. |
transport
|
|
gmail/mocks
Package mock_gmail is a generated GoMock package.
|
Package mock_gmail is a generated GoMock package. |
smtp/mocks
Package mock_smtp is a generated GoMock package.
|
Package mock_smtp is a generated GoMock package. |