email

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2022 License: Artistic-2.0 Imports: 6 Imported by: 0

README

��# email

�[�s�{US�v text , html , file D��N�v�mo`�S�

O(udemo

func TestMaintest(t *testing.T) {
	email := NewClient("xxxxx@qq.com", "xxxasaxxasx", "smtp.qq.com")
	email.Name("aurora-email Manager")
	email.Subject("KmՋ���N")
	email.Text("test nf��e,g�mo`")
	email.Html(`<!DOCTYPE html>
	<html lang="en">
		<head>
	     <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		   <title>Title</title>
		</head>
		<body>
			<p style="font-size:30px;color:orange">KmՋHTML �Oo`</p>
		</body>
	</html>`)

	//�m�RN*Npdf
	file, err := os.ReadFile("1111.pdf")
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	email.File("test.pdf", file)

	//�m�RN����PN
	file, err = os.ReadFile("Hillsong Young & Free - Wake (Studio) [mqms2].flac")
	if err != nil {
		fmt.Println(err.Error())
		return
	}
	email.File("Hillsong Young & Free - Wake (Studio) [mqms2].flac", file)

	_, err = email.SendEmail("asd.asdas@xxxx.com", "asdawq@qq.com")
	if err != nil {
		fmt.Println(err.Error())
		return
	}
}

Documentation

Index

Constants

View Source
const (
	CRLF                    = "\r\n"                      //解析分隔标记
	Subject                 = "Subject"                   //邮件主题
	From                    = "From"                      //发件人信息
	To                      = "To"                        //收件人信息
	Data                    = "Data"                      //指定邮件发送时间
	ContentType             = "Content-Type"              //指定消息类型
	ContentTransferEncoding = "Content-Transfer-Encoding" //指定消息编码格式
	ContentDisposition      = "Content-Disposition"
	MIME                    = "MIME-Version"
	Base64                  = "Base64"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(user, password, host string) *Client

NewClient 生成一个Email客户端

func (*Client) File

func (c *Client) File(name string, data []byte)

File 设置发送邮件的附件信息 文件默认的传输格式采用Base64 File 可以多次添加并不会产生覆盖

func (*Client) Html

func (c *Client) Html(html string)

Html 设置发送的超文本信息

func (*Client) Name

func (c *Client) Name(name string)

Name 设置发送者昵称

func (*Client) SendEmail

func (c *Client) SendEmail(addr ...string) (bool, error)

SendEmail 发送邮件信息 可选多个地址

func (*Client) Subject

func (c *Client) Subject(title string)

Subject 设置邮件标题信息

func (*Client) Text

func (c *Client) Text(text string)

Text 设置发送的文本信息

type File

type File struct {
	Filename         string   //文件名称
	Type             []string //内容类型
	Disposition      []string //文件描述
	TransferEncoding string   //传输编码
	Encoding         string   //编码后的字符串
	// contains filtered or unexported fields
}

File 邮件附件信息

type Header struct {
	Name  string   //头名
	Value []string //头的内容属性
}

Header Email 头信息结构

func NewHeader

func NewHeader(name string, attr ...string) *Header

NewHeader 创建新的 Header

func (*Header) AddAttr

func (h *Header) AddAttr(name string, value ...string)

AddAttr 设置 Header 的属性内容

func (*Header) Encoding

func (h *Header) Encoding() []byte

Encoding Header 编码生成指定格式的消息组合部分

type Message

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

Message 邮件中的消息部分

func (*Message) Next

func (m *Message) Next(msg *Message)

Next 附加一个消息

Jump to

Keyboard shortcuts

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