utils

package
v0.0.0-...-fea8a0b Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2021 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RECODE_OK         = "0"
	RECODE_DBERR      = "4001"
	RECODE_NODATA     = "4002"
	RECODE_DATAEXIST  = "4003"
	RECODE_DATAERR    = "4004"
	RECODE_SESSIONERR = "4101"
	RECODE_LOGINERR   = "4102"
	RECODE_PARAMERR   = "4103"
	RECODE_USERERR    = "4104"
	RECODE_ROLEERR    = "4105"
	RECODE_PWDERR     = "4106"
	RECODE_SMSERR     = "4017"
	RECODE_REQERR     = "4201"
	RECODE_IPERR      = "4202"
	RECODE_THIRDERR   = "4301"
	RECODE_IOERR      = "4302"
	RECODE_SERVERERR  = "4500"
	RECODE_UNKNOWERR  = "4501"
)

Variables

This section is empty.

Functions

func AddDomain2Url

func AddDomain2Url(url string) (domain_url string)

func Md5String

func Md5String(s string) string

func RecodeText

func RecodeText(code string) string

func SendEmail

func SendEmail(emailTo string, code string) error

func Sha256Encode

func Sha256Encode(value string) string

func UploadByBuffer

func UploadByBuffer(filebuffer []byte, fileExt string) (string, error)

Types

type Attachment

type Attachment struct {
	Filename string
	Header   textproto.MIMEHeader
	Content  []byte
}

Attachment is a struct representing an email attachment. Based on the mime/multipart.FileHeader struct, Attachment contains the name, MIMEHeader, and content of the attachment in question

type Email

type Email struct {
	Auth        smtp.Auth
	Identity    string `json:"identity"`
	Username    string `json:"username"`
	Password    string `json:"password"`
	Host        string `json:"host"`
	Port        int    `json:"port"`
	From        string `json:"from"`
	To          []string
	Bcc         []string
	Cc          []string
	Subject     string
	Text        string // Plaintext message (optional)
	HTML        string // Html message (optional)
	Headers     textproto.MIMEHeader
	Attachments []*Attachment
	ReadReceipt []string
}

Email is the type used for email messages

func NewEMail

func NewEMail(config string) *Email

NewEMail create new Email struct with config json. config json is followed from Email struct fields.

func (*Email) Attach

func (e *Email) Attach(r io.Reader, filename string, args ...string) (a *Attachment, err error)

Attach is used to attach content from an io.Reader to the email. Parameters include an io.Reader, the desired filename for the attachment, and the Content-Type.

func (*Email) AttachFile

func (e *Email) AttachFile(args ...string) (a *Attachment, err error)

AttachFile Add attach file to the send mail

func (*Email) Bytes

func (e *Email) Bytes() ([]byte, error)

Bytes Make all send information to byte

func (*Email) Send

func (e *Email) Send() error

Send will send out the mail

Jump to

Keyboard shortcuts

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