mail

package
v0.0.0-...-0286adb Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 全局命令
	IMAP_CAPABILITY = "CAPABILITY"
	IMAP_NOOP       = "NOOP"
	IMAP_LOGOUT     = "LOGOUT"

	//未认证状态命令
	IMAP_STARTTLS     = "STARTTLS"
	IMAP_AUTHENTICATE = "AUTHENTICATE"
	IMAP_LOGIN        = "LOGIN"

	// 认证状态命令
	IMAP_SELECT      = "SELECT"
	IMAP_EXAMINE     = "EXAMINE"     // 选择文件夹只读方式
	IMAP_CREATE      = "CREATE"      // 创建一个文件夹
	IMAP_DELETE      = "DELETE"      // 删除一个文件夹
	IMAP_RENAME      = "RENAME"      // 重命名一个文件
	IMAP_SUBSCRIBE   = "SUBSCRIBE"   // 订阅指定的邮箱地址
	IMAP_UNSUBSCRIBE = "UNSUBSCRIBE" // 取消订阅
	IMAP_LIST        = "LIST"        // 返回详细的文件夹列表
	IMAP_LSUB        = "LSUB"        // 返回订阅的邮箱地址列表
	IMAP_STATUS      = "STATUS"      // 请求返回指定邮箱文件夹的状态
	IMAP_APPEND      = "APPEND"      // 追加一个状态,例如可以保存一封新的邮件

	// 选中状态指令
	IMAP_CHECK   = "CHECK"   // 检查当前服务器状态(例如:磁盘,内存等)
	IMAP_CLOSE   = "CLOSE"   // 永久删除所有消息
	IMAP_EXPUNGE = "EXPUNGE" // 永久删除所有消息,与CLOSE不同的是,将返回每个消息标识
	IMAP_SEARCH  = "SEARCH"  // 类似linux系统find命令,功能很强大可以按照不同条件搜索邮件
	IMAP_FETCH   = "FETCH"   // 检索与消息相关数据,例如:获取正文
	IMAP_STORE   = "STORE"   // 改变与消息相关数据,例如:设置邮箱已读、删除状态等
	IMAP_COPY    = "COPY"    // 拷贝指定的消息
	IMAP_UID     = "UID"     // 返回UID列表用于fetch
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attachment

type Attachment struct {
	Filepath string //当前的全路径
	Data     []byte
	Inline   bool
	Cid      string
}

附件/内联图片

type Client

type Client struct {
	// Text is the textproto.Conn used by the Client. It is exported to allow for
	// clients to add extensions.
	Text *textproto.Conn
	// contains filtered or unexported fields
}

func Dial

func Dial(addr string) (*Client, error)

Dial returns a new Client connected to an SMTP server at addr. The addr must include a port, as in "mail.example.com:smtp".

func NewClient

func NewClient(conn net.Conn, host string) (*Client, error)

NewClient returns a new Client using an existing connection and host as a server name to be used when authenticating.

func (*Client) Authenticate

func (c *Client) Authenticate() error

func (*Client) Capability

func (c *Client) Capability() error

全局命令 CAPABILITY、服务器响应能力描述,此指令个人理解是当前邮件服务器的能力。 NOOP、与服务器保持连接,可以用来新邮件或者消息状态更新。 LOGOUT、终端服务器连接

func (*Client) Close

func (c *Client) Close() error

Close closes the connection.

func (*Client) Login

func (c *Client) Login(username, password string) error

func (*Client) Logout

func (c *Client) Logout() error

func (*Client) Noop

func (c *Client) Noop() error

func (*Client) Starttls

func (c *Client) Starttls() error

未认证状态命令 STARTTLS、与服务器使用TLS进行交互 AUTHENTICATE、与服务器的认证机制 LOGIN、鉴权登陆,输入用户名与密码

type GoMail

type GoMail struct {
	From         string        // 发件人
	To           []string      // 收件人
	Cc           []string      // 抄送
	Bcc          []string      // 密送
	Subject      string        // 标题
	Message      string        // 正文
	Attachments  []*Attachment // 附件
	InlineAttach []*Attachment // 内联附件
}

邮件

func (*GoMail) WriterEmail

func (m *GoMail) WriterEmail() ([]byte, error)

编码邮件内容到数据流

type GoMailServer

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

服务器配置

func NewGoMailServer

func NewGoMailServer(username, password, smtpUri, imapUri string, smtpPort, imapPort int) *GoMailServer

func (*GoMailServer) ReceiveMail

func (server *GoMailServer) ReceiveMail() ([]GoMail, error)

接收邮件

func (*GoMailServer) SendMail

func (server *GoMailServer) SendMail(goMail *GoMail) (bool, error)

发送邮件

type NotAuthenticated

type NotAuthenticated struct{}

Not Authenticated State: 非认证状态

func (*NotAuthenticated) Error

func (err *NotAuthenticated) Error() string

Jump to

Keyboard shortcuts

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