email

package
v1.0.26 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: MIT Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAddress

func ParseAddress(s string) (*mail.Address, error)

ParseAddress parse email address

Types

type Attachment

type Attachment struct {
	Cid  string
	Name string
	Data io.Reader
}

Attachment email attachment

func NewAttachment

func NewAttachment(cid string, name string, data io.Reader) (*Attachment, error)

NewAttachment new a email attachment

func (*Attachment) IsInline

func (a *Attachment) IsInline() bool

IsInline return true if cid is not empty

type DirectSender

type DirectSender struct {
	Sender
}

DirectSender direct send email

func (*DirectSender) DirectSend

func (ds *DirectSender) DirectSend(ms ...*Email) error

DirectSend lookup MX record and direct send to recipter's mail server

type Email

type Email struct {
	MsgID       string
	Date        time.Time
	Subject     string
	Message     string
	HTML        bool
	Attachments []*Attachment

	DkimDomain     string
	DkimSelector   string
	DkimPrivateKey string
	// contains filtered or unexported fields
}

Email email struct

func (*Email) AddAttachment

func (m *Email) AddAttachment(as ...*Attachment)

AddAttachment add a attachment

func (*Email) AddBcc

func (m *Email) AddBcc(bccs ...string) error

AddBcc add bcc address

func (*Email) AddCc

func (m *Email) AddCc(ccs ...string) error

AddCc add cc address

func (*Email) AddReply

func (m *Email) AddReply(rs ...string) error

AddReply add reply address

func (*Email) AddTo

func (m *Email) AddTo(tos ...string) error

AddTo add to address

func (*Email) AttachFile

func (m *Email) AttachFile(paths ...string) error

AttachFile attach a file

func (*Email) AttachString

func (m *Email) AttachString(name string, data string)

AttachString attach a string date file

func (*Email) EmbedFile

func (m *Email) EmbedFile(cid string, path string) error

EmbedFile embed a file

func (*Email) EmbedString

func (m *Email) EmbedString(cid string, name string, data string)

EmbedString embed a string date file

func (*Email) GetBccs

func (m *Email) GetBccs() []*mail.Address

GetBccs get bcc address array

func (*Email) GetCcs

func (m *Email) GetCcs() []*mail.Address

GetCcs get cc address array

func (*Email) GetDate

func (m *Email) GetDate() time.Time

GetDate return the email date

func (*Email) GetFrom

func (m *Email) GetFrom() *mail.Address

GetFrom get from

func (*Email) GetRecipients

func (m *Email) GetRecipients() []string

GetRecipients get all recipients

func (*Email) GetRecipientsByDomain

func (m *Email) GetRecipientsByDomain() map[string][]string

GetRecipientsByDomain return a (domain => address string array) map

func (*Email) GetReplys

func (m *Email) GetReplys() []*mail.Address

GetReplys get reply address array

func (*Email) GetSender

func (m *Email) GetSender() string

GetSender get sender

func (*Email) GetTos

func (m *Email) GetTos() []*mail.Address

GetTos get to address array

func (*Email) SetFrom

func (m *Email) SetFrom(s string) error

SetFrom set from

func (*Email) SetHTMLMsg

func (m *Email) SetHTMLMsg(msg string)

SetHTMLMsg set the HTML message

func (*Email) SetSender

func (m *Email) SetSender(s string) error

SetSender set sender

func (*Email) SetTextMsg

func (m *Email) SetTextMsg(msg string)

SetTextMsg set the text message

type SMTPSender

type SMTPSender struct {
	// Host represents the host of the SMTP server.
	Host string

	// Port represents the port of the SMTP server.
	Port int

	// Username is the username to use to authenticate to the SMTP server.
	Username string

	// Password is the password to use to authenticate to the SMTP server.
	Password string

	// Auth represents the authentication mechanism used to authenticate to the
	// SMTP server.
	Auth smtp.Auth

	Sender
}

SMTPSender SMTP email sender

func (*SMTPSender) Dial

func (ss *SMTPSender) Dial() error

Dial dials and authenticates to an SMTP server. Should call Close() when done.

func (*SMTPSender) DialAndSend

func (ss *SMTPSender) DialAndSend(ms ...*Email) error

DialAndSend opens a connection to the SMTP server, sends the given emails and closes the connection.

func (*SMTPSender) Login

func (ss *SMTPSender) Login() error

Login login smtp server

func (*SMTPSender) Send

func (ss *SMTPSender) Send(ms ...*Email) error

Send send mail to SMTP server.

type Sender

type Sender struct {
	// LocalName is the hostname sent to the SMTP server with the HELO command.
	// By default, "localhost" is sent.
	Helo string

	// Timeout timeout when connect to the SMTP server
	Timeout time.Duration

	// SSL defines whether an SSL connection is used. It should be false in
	// most cases since the authentication mechanism should use the STARTTLS
	// extension instead.
	SSL bool

	// SkipTLS Skip StartTLS when the STARTTLS extension is used
	SkipTLS bool

	// TSLConfig represents the TLS configuration used for the TLS (when the
	// STARTTLS extension is used) or SSL connection.
	TLSConfig *tls.Config

	// ConnDebug  a conn wrap func
	ConnDebug func(conn net.Conn) net.Conn

	// DataDebug  a data writer wrap func
	DataDebug func(w io.Writer) io.Writer
	// contains filtered or unexported fields
}

Sender email sender

func (*Sender) Close

func (s *Sender) Close() error

Close close the SMTP client

func (*Sender) IsDialed

func (s *Sender) IsDialed() bool

IsDialed return true if the sender is dialed

Jump to

Keyboard shortcuts

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