njs_smtp

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment interface {
	Clone() Attachment

	GetContentType() string
	GetName() string
	GetBuffer() *bytes.Buffer

	Write(p []byte) (n int, e error)
	WriteString(s string) (n int, e error)
	WriteRune(r rune) (n int, e error)
}

func NewAttachment

func NewAttachment(name string) Attachment

func NewAttachmentFile

func NewAttachmentFile(name string, filepath string) (Attachment, error)

type ContentType

type ContentType uint8
const (
	CONTENTTYPE_MIXED ContentType = iota
	CONTENTTYPE_ALTERNATIVE
	CONTENTTYPE_HTML
	CONTENTTYPE_TEXT
)

func (ContentType) String

func (c ContentType) String() string

type IOData

type IOData interface {
	ContentType(ct ContentType, charset string) error
	Header(key, value string) error
	String(value string) error
	Bytes(value []byte) error
	CRLF() error

	Send() error
	GetBuffer() *bytes.Buffer

	AttachmentStart(c ContentType) error
	AttachmentAddFile(contentType, attachmentName string, attachment *bytes.Buffer) error
	AttachmentAddBody(m MailTemplate, ct ContentType) error
	AttachmentEnd() error
}

func NewIOData

func NewIOData(cli *smtp.Client) (IOData, error)

type ListMailAddress

type ListMailAddress interface {
	Len() int
	IsEmpty() bool
	String() string
	Clone() ListMailAddress

	Merge(list ListMailAddress)
	Slice() []MailAddress

	AddressOnly() string

	Add(adr ...MailAddress)
	AddParseEmail(m ...string)
	AddNewEmail(name, addr string)
}

func NewListMailAddress

func NewListMailAddress() ListMailAddress

type MailAddress

type MailAddress interface {
	Clone() MailAddress

	ForceName(name string)
	ForceAddress(address string)

	String() string
	AddressOnly() string
}

func MailAddressParser

func MailAddressParser(str string) MailAddress

func NewMailAddress

func NewMailAddress(name, address string) MailAddress

type MailTemplate

type MailTemplate interface {
	Clone() (MailTemplate, error)

	IsEmpty() bool

	SetCharset(char string)
	GetCharset() string

	SetTextOption(opt html2text.Options)
	GetTextOption() html2text.Options

	GetBufferHtml(data interface{}) (*bytes.Buffer, error)
	GetBufferText(data interface{}) (*bytes.Buffer, error)
	GetBufferRich(data interface{}) (*bytes.Buffer, error)

	RegisterData(data interface{})
}

func NewMailTemplate

func NewMailTemplate(name, tpl string, isFile bool) (MailTemplate, error)

type NETMode

type NETMode uint8
const (
	NET_TCP NETMode = iota
	NET_TCP_4
	NET_TCP_6
	NET_UNIX
)

type SMTP

type SMTP interface {
	Client() (*smtp.Client, error)
	Close()
	Check() error
	Clone() SMTP

	ForceHost(host string)
	ForcePort(port int)
	ForceUser(user string)
	ForcePass(pass string)
	ForceNet(mode NETMode)
	ForceTls(mode TLSMode)
	ForceTLSSkipVerify(skip bool)
	ForceTLSServerName(serverName string)

	GetDsn() string
}

func NewSMTP

func NewSMTP(dsn string, tlsConfig *tls.Config) (SMTP, error)

NewSMTP return a SMTP interface to operation negotiation with a SMTP server the dsn parameter must be string like this '[user[:password]@][net[(addr)]]/tlsmode[?param1=value1&paramN=valueN]"

  • params available are : ServerName (string), SkipVerify (boolean)
  • tls mode acceptable are : starttls, tls, <any other value to no tls/startls>
  • net aceeptable are : tcp4, tcp6, unix

type SendMail

type SendMail interface {
	SetListTo(listMail ListMailAddress)
	GetToString() string
	SetTo(mail ...MailAddress)
	AddTo(mail ...MailAddress)

	SetListCc(listMail ListMailAddress)
	SetCc(mail ...MailAddress)
	AddCc(mail ...MailAddress)

	SetListBcc(listMail ListMailAddress)
	SetBcc(mail ...MailAddress)
	AddBcc(mail ...MailAddress)

	SetFrom(mail MailAddress)
	SetReplyTo(mail MailAddress)

	SetSubject(subject string)
	SetHtml(m MailTemplate)
	HtmlRegisterData(data interface{})
	SetBody(p *bytes.Buffer)
	SetForceOnly(ct ContentType)
	AddAttachment(a ...Attachment)

	SetMessageId(id string)
	SetMailer(mailer string)
	NJSMailer(version njs_version.Version)

	SetTestMode(enable bool)

	Clone() (SendMail, error)
	Send(cli *smtp.Client) (err error, buff *bytes.Buffer)
	SendSMTP(cli SMTP) (err error, buff *bytes.Buffer)
}

func NewSendMail

func NewSendMail() SendMail

type TLSMode

type TLSMode uint8
const (
	TLS_NONE TLSMode = iota
	TLS_STARTTLS
	TLS_TLS
)

Jump to

Keyboard shortcuts

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