utils

package module
v0.0.0-...-a89e01d Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: MIT Imports: 18 Imported by: 0

README

utils

通用的一些操作的封装

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
	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 BeeMap

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

BeeMap is a map with lock

func NewBeeMap

func NewBeeMap() *BeeMap

NewBeeMap return new safemap

func (*BeeMap) Check

func (m *BeeMap) Check(k interface{}) bool

Check Returns true if k is exist in the map.

func (*BeeMap) Delete

func (m *BeeMap) Delete(k interface{})

Delete the given key and value.

func (*BeeMap) Get

func (m *BeeMap) Get(k interface{}) interface{}

Get from maps return the k's value

func (*BeeMap) Items

func (m *BeeMap) Items() map[interface{}]interface{}

Items returns all items in safemap.

func (*BeeMap) Set

func (m *BeeMap) Set(k interface{}, v interface{}) bool

Set Maps the given key and value. Returns false if the key is already in the map and changes nothing.

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

func (*Email) SendUsingTLS

func (e *Email) SendUsingTLS() error

SendUsingTLS will send out the mail using TLS

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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