goususmtp

package module
v2.0.0-...-b942c1c Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 9 Imported by: 0

README

SMTP-Integration for Go Universal Service Utilities

Full docu for go-gousu on https://github.com/indece-official/go-gousu

GoDoc

Usage

Config flags
Flag Env-Var Type Default Description
smtp_host SMTP_HOST string "127.0.0.1" SMTP-Server hostname or ip
smtp_port SMTP_PORT int 587 SMTP-Server port
smtp_user SMTP_USER string "" User for authentication against SMTP-Server
smtp_password SMTP_PASSWORD string "" Password for authentication against SMTP-Server
smtp_from SMTP_FROM string "" Default From-Header in emails

TODO

Documentation

Index

Constants

View Source
const ServiceName = "smtp"

ServiceName defines the name of smtp service used for dependency injection

Variables

This section is empty.

Functions

func NewService

func NewService(ctx gousu.IContext) gousu.IService

NewService if the ServiceFactory for an initialized Service

Types

type Email

type Email struct {
	// From is the name of the sender
	// If empty the config flag 'smtp_from' is used
	From         string
	To           string
	Subject      string
	BodyPlain    string
	BodyHTML     string
	Attachements []EmailAttachement
}

Email defines the base model of an email

type EmailAttachement

type EmailAttachement struct {
	Filename string
	Mimetype string
	Embedded bool
	Content  []byte
}

EmailAttachement defines the base model of an email attachemet

type IService

type IService interface {
	gousu.IService

	SendEmail(m *Email) error
}

IService defines the interface of the smtp service

type MockService

type MockService struct {
	gousu.MockService

	SendEmailFunc       func(m *Email) error
	SendEmailFuncCalled int
}

MockService for simply mocking IService

func NewMockService

func NewMockService() *MockService

NewMockService creates a new initialized instance of MockService

func (*MockService) SendEmail

func (s *MockService) SendEmail(m *Email) error

SendEmail calls SendEmailFunc and increases SendEmailFuncCalled

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides an smtp sender running in a separate thread

func (*Service) Health

func (s *Service) Health() error

Health checks if the MailService is healthy

func (*Service) Name

func (s *Service) Name() string

Name returns the name of the smtp service from ServiceName

func (*Service) SendEmail

func (s *Service) SendEmail(m *Email) error

SendEmail sents a mail via SMTP

func (*Service) Start

func (s *Service) Start() error

Start starts the SMTP-Sender in a separate thread

func (*Service) Stop

func (s *Service) Stop() error

Stop stops the SMTP-Sender thread

Jump to

Keyboard shortcuts

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