xmusemail

package module
v0.0.0-...-50bb6cb Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: MIT Imports: 7 Imported by: 0

README

xmus-email

simple email client using net/SMTP

sample usage :

auth := xmusemail.Auth{
	Host:     "mail.yourdomain.com",
	Port:     465,
	From:     "target@anotherdomain.com",
	Password: "passWordHere",
}
logger := xmuslogger.CreateLogger(&xmuslogger.LoggerOptions{LogLevel: xmuslogger.Error})
log := logger.BeginWithPrefix("[xmus-email]")
e := xmusemail.NewSMTP(auth,
	&tls.Config{
		InsecureSkipVerify: true,
		ServerName:         "mail.yourdomain.com",
	},
	log,
	true,
)
msessage := xmusemail.Message{
	"<%PLACE%>":   "in google meet =)",
	"<%HEADER%>":  "some fancy header here",
	"<%MESSAGE%>": "Lorem ipsu dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia mollit anim id est laborum.",
	"<%FOOTER%>":  "copyright my company",
}
err := e.Send(msessage, "subject", xmusemail.SampleHolloweenTemplate, "amupxm@gmail.com")
if err != nil {
	log.Error(err)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientIsNotValid   = errors.New("Client is not valid")
	ErrUnauthorized       = errors.New("auth is not valid")
	ErrYourEmailIsInvalid = errors.New("Your email is invalid")
	ErrRCPTConnection     = errors.New("rcpt connection error")
	ErrOnDataCommand      = errors.New("on data command error")
	ErrOnWriteData        = errors.New("on write data error")
	ErrOnCloseDataPipe    = errors.New("on close data pipe error")
)

Xmus errors

View Source
var SampleHolloweenTemplate = `` /* 17856-byte string literal not displayed */

SampleHolloweenTemplate is a sample template for the email

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	Password string `json:"password"`
	From     string `json:"from"`
}

Auth is the authentication information for the SMTP server

type EngineKey

type EngineKey string

EngineKey is the key of the message

type EngineValue

type EngineValue interface{}

EngineValue is the value of the message

type LeveledLoggerInterface

type LeveledLoggerInterface interface {
	// Debugf logs a debug message using Printf conventions.
	Debugf(format string, v ...interface{})

	// Errorf logs a warning message using Printf conventions.
	Errorf(format string, v ...interface{})

	// Infof logs an informational message using Printf conventions.
	Infof(format string, v ...interface{})

	// Warnf logs a warning message using Printf conventions.
	Warnf(format string, v ...interface{})
}

LeveledLoggerInterface is the interface for leveled logger

type Message

type Message map[EngineKey]EngineValue

Message is the basic message

type SMTP

type SMTP interface {
	Send(message Message, subject, template string, to ...string) error
}

SMTP is the basic SMTP client

func NewSMTP

func NewSMTP(auth Auth, tlsConfig *tls.Config, logger LeveledLoggerInterface, log bool) SMTP

NewSMTP creates a new SMTP client

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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