mailing

package
v0.0.0-...-6f28fd0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogSender

type LogSender struct {
	From   mail.Address
	Logger log.Logger
}

LogSender log emails.

func NewLogSender

func NewLogSender(from string, l log.Logger) *LogSender

NewLogSender implementation using the provided logger.

func (*LogSender) Send

func (s *LogSender) Send(to, subject, html, text string) error

Send will just log the email.

type SMTPSender

type SMTPSender struct {
	From mail.Address
	Addr string
	Auth smtp.Auth
}

SMTPSender sends emails using an SMTP nakama.

func NewSMTPSender

func NewSMTPSender(from, host string, port int, username, password string) *SMTPSender

NewSMTPSender implementation using an SMTP server.

func (*SMTPSender) Send

func (s *SMTPSender) Send(to, subject, html, text string) error

Send an email to the given email address.

type Sender

type Sender interface {
	Send(to, subject, html, text string) error
}

Sender sends mails.

type SenderMock

type SenderMock struct {
	// SendFunc mocks the Send method.
	SendFunc func(to string, subject string, html string, text string) error
	// contains filtered or unexported fields
}

SenderMock is a mock implementation of Sender.

func TestSomethingThatUsesSender(t *testing.T) {

	// make and configure a mocked Sender
	mockedSender := &SenderMock{
		SendFunc: func(to string, subject string, html string, text string) error {
			panic("mock out the Send method")
		},
	}

	// use mockedSender in code that requires Sender
	// and then make assertions.

}

func (*SenderMock) Send

func (mock *SenderMock) Send(to string, subject string, html string, text string) error

Send calls SendFunc.

func (*SenderMock) SendCalls

func (mock *SenderMock) SendCalls() []struct {
	To      string
	Subject string
	HTML    string
	Text    string
}

SendCalls gets all the calls that were made to Send. Check the length with:

len(mockedSender.SendCalls())

type SendgridSender

type SendgridSender struct {
	From   mail.Address
	APIKey string
}

func NewSendgridSender

func NewSendgridSender(from, apiKey string) *SendgridSender

func (*SendgridSender) Send

func (s *SendgridSender) Send(to, subject, html, text string) error

Jump to

Keyboard shortcuts

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