mailx

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 18 Imported by: 0

README

mailx

Documentation

Index

Constants

View Source
const (
	HeaderContentTransferEncoding = "Content-Transfer-Encoding"
	HeaderContentType             = "Content-Type"
	HeaderContentDisposition      = "Content-Disposition"

	CTE_Q = "quoted-printable"
	CTE_B = "base64"
)

Variables

This section is empty.

Functions

func NewRFC822

func NewRFC822(w io.Writer) io.Writer

NewRFC822 Creates a RFC822 text wrapper. It adds a CRLF (ie. \r\n) each 76 characters.

func Send

func Send(ctx context.Context, rcpts []string, body Body, serverOpts ServerOption) (err error)

Types

type Address

type Address struct {
	Name    string `json:"name,omitempty"`
	Address string `json:"address,omitempty"`
}

func (*Address) Set

func (a *Address) Set(address string, name ...string)

func (*Address) String

func (a *Address) String() string

type AddressList

type AddressList []*Address

func ParseAddressList

func ParseAddressList(addressList ...string) (out AddressList, err error)

func (*AddressList) Add

func (l *AddressList) Add(address ...string) (err error)

func (*AddressList) AddAddress added in v0.0.2

func (l *AddressList) AddAddress(addrs ...*Address)

func (*AddressList) AddOne added in v0.0.2

func (l *AddressList) AddOne(address string, name ...string)

func (*AddressList) At

func (l *AddressList) At(index int) (find *Address)

func (*AddressList) Purge

func (l *AddressList) Purge()

func (*AddressList) Rcpts

func (l *AddressList) Rcpts() []string

func (*AddressList) String

func (l *AddressList) String() string

func (*AddressList) Text

func (l *AddressList) Text() []string

type Attachment

type Attachment struct {
	Name string
	Body
}

Attachment 附件结构

type AttachmentList

type AttachmentList []*Attachment

AttachmentList 附件集合

func (*AttachmentList) Add

func (list *AttachmentList) Add(name string, body Body)

Add 增加附件

type Body

type Body func(w io.Writer) (err error)

func BodyFromFile

func BodyFromFile(fn string) Body

BodyFromFile 从本地文件构造附件

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

Header 媒体头

func (*Header) Add

func (hdr *Header) Add(k, v string)

Add 添加键值对

func (*Header) Boundary

func (hdr *Header) Boundary() string

Boundary is empty but content-type is multipart

func (*Header) Del

func (hdr *Header) Del(k string)

Del 删除指定键

func (*Header) Each

func (hdr *Header) Each(walkFn func(k, v string))

func (*Header) Get

func (hdr *Header) Get(k string) (v string)

Get 获取值

func (*Header) GetContentTransferEncoding

func (hdr *Header) GetContentTransferEncoding() string

GetContentTransferEncoding 获取 ContentTransferEncoding

func (*Header) HeaderBytes

func (hdr *Header) HeaderBytes() []byte

HeaderBytes 编码成字节

func (*Header) Set

func (hdr *Header) Set(k, v string)

Set 设置指定键的值,存在则替换,不存在则添加,值为空则删除

func (*Header) SetContentDisposition

func (hdr *Header) SetContentDisposition(contentDisposition string, params ...string)

SetContentDisposition 设置内容的编码处理方式

func (*Header) SetContentTransferEncoding

func (hdr *Header) SetContentTransferEncoding(cte string)

SetContentTransferEncoding 设置内容的传输编码方式,name: "quoted-printable", "base64"

func (*Header) SetContentType

func (hdr *Header) SetContentType(mimetype string, params ...string)

SetContentType 设置ContentType

func (*Header) SetMultipartType

func (hdr *Header) SetMultipartType(partType string)

SetMultipartType 设置为多媒体类型

func (*Header) SetText

func (hdr *Header) SetText(k, v string)

SetText 设置指定键的值,值会被编码

func (*Header) SetTextType

func (hdr *Header) SetTextType(textType string)

SetTextType 设置ContentType为文本类型

func (*Header) WriteTo added in v0.0.2

func (hdr *Header) WriteTo(w io.Writer) (int64, error)

type Message added in v0.0.2

type Message struct {
	To         AddressList
	Cc         AddressList
	Bcc        AddressList
	Subject    string
	Content    string
	Attach     AttachmentList
	From       Address
	ReplyTo    Address
	ReturnPath Address
	Headers    Header
}

Message 邮件消息模型

func NewMail added in v0.0.2

func NewMail() *Message

func (*Message) Encode added in v0.0.2

func (msg *Message) Encode(w io.Writer) (err error)

Encode 编码邮件并写入

func (*Message) Rcpts added in v0.0.2

func (msg *Message) Rcpts() (out []string)

func (*Message) Send added in v0.0.2

func (msg *Message) Send(ctx context.Context, sOpts ServerOption) (err error)

Send 发送邮件

type ServerOption

type ServerOption struct {
	Name string `json:"name,omitempty"`
	From string `json:"from,omitempty"`
	User string `json:"user,omitempty"`
	Pass string `json:"pass,omitempty"`
	Host string `json:"host,omitempty"`
	Port string `json:"port,omitempty"`
}

func (ServerOption) String

func (server ServerOption) String() string

func (ServerOption) Valid

func (server ServerOption) Valid() error

Jump to

Keyboard shortcuts

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