gg_email

package
v0.2.37 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Filename string
	Data     []byte
	Inline   bool
}

Attachment represents an email attachment.

type EmailHelper

type EmailHelper struct {
}
var Email *EmailHelper

func (*EmailHelper) NewHTMLMessage

func (instance *EmailHelper) NewHTMLMessage(subject string, body string) *Message

NewHTMLMessage returns a new Message that can compose an HTML email with attachments

func (*EmailHelper) NewMessage

func (instance *EmailHelper) NewMessage(subject string, body string) *Message

NewMessage returns a new Message that can compose an email with attachments

func (*EmailHelper) NewSender

func (instance *EmailHelper) NewSender(settings ...interface{}) (*SmtpSender, error)

NewSender returns a new Message Sender

func (*EmailHelper) Send

func (instance *EmailHelper) Send(addr string, auth smtp.Auth, m *Message) error

Send sends the message.

func (*EmailHelper) SendMessage

func (instance *EmailHelper) SendMessage(host string, port int, secure bool, user string, pass string,
	from, replyTo string, to, bcc, cc string, subject string, text string, html string, attachments []interface{}) (err error)

func (*EmailHelper) SendSecure

func (instance *EmailHelper) SendSecure(addr string, auth smtp.Auth, tlsConfig *tls.Config, m *Message) error

SendSecure sends the message over TLS.

type Header struct {
	Key   string
	Value string
}

Header represents an additional email header.

type Message

type Message struct {
	From            *mail.Address
	To              []string
	Cc              []string
	Bcc             []string
	ReplyTo         string
	Subject         string
	Body            string
	BodyContentType string
	Headers         []Header
	Attachments     map[string]*Attachment
}

Message represents a smtp message.

func (*Message) AddAttachment

func (m *Message) AddAttachment(file string) error

AddAttachment attaches a file.

func (*Message) AddAttachmentBinary

func (m *Message) AddAttachmentBinary(filename string, buf []byte, inline bool) error

AddAttachmentBinary attaches a binary attachment.

func (*Message) AddAttachmentInline

func (m *Message) AddAttachmentInline(file string) error

AddAttachmentInline includes a file as an inline attachment.

func (*Message) AddBcc

func (m *Message) AddBcc(address mail.Address) []string

func (*Message) AddCc

func (m *Message) AddCc(address mail.Address) []string

func (*Message) AddHeader

func (m *Message) AddHeader(key string, value string) Header

AddHeader Ads a Header to message

func (*Message) AddTo

func (m *Message) AddTo(address mail.Address) []string

func (*Message) GetBytes

func (m *Message) GetBytes() []byte

GetBytes returns the mail data

func (*Message) GetToList

func (m *Message) GetToList() []string

GetToList returns all the recipients of the email

type SmtpSender

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

func (*SmtpSender) Configure

func (instance *SmtpSender) Configure(settings interface{}) (err error)

func (*SmtpSender) Send

func (instance *SmtpSender) Send(subject, body string, to, bcc, cc []string, from, replyTo string, attachments []string) error

func (*SmtpSender) SendAsync

func (instance *SmtpSender) SendAsync(subject, body string, to, bcc, cc []string, from, replyTo string, attachments []string, callback func(error))

func (*SmtpSender) SendMessage

func (instance *SmtpSender) SendMessage(message *Message) (err error)

func (*SmtpSender) SendMessageAsync

func (instance *SmtpSender) SendMessageAsync(message *Message, callback func(error))

type SmtpSettings

type SmtpSettings struct {
	Host    string            `json:"host"`
	Port    int               `json:"port"`
	Secure  bool              `json:"secure"`
	Auth    *SmtpSettingsAuth `json:"auth"`
	From    string            `json:"from"`
	ReplyTo string            `json:"reply_to"`
}

type SmtpSettingsAuth

type SmtpSettingsAuth struct {
	User string `json:"user"`
	Pass string `json:"pass"`
}

Jump to

Keyboard shortcuts

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