imap

package
v1.0.29 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSearchNil = errors.New("search result is nil")

Functions

func GetCurrentNum added in v1.0.25

func GetCurrentNum() uint32

获取当前读取到的邮件索引

func Keepalive added in v1.0.24

func Keepalive()

通过noop保持imap连接

func Logout added in v1.0.24

func Logout()

func NewClient

func NewClient(address, user, password string, num uint32) error

func Reconnect added in v1.0.24

func Reconnect() error

func SetAnsweredFlag added in v1.0.24

func SetAnsweredFlag(uid uint32) error

通过UID设置邮件Answered Flag

func UnReadMailsUID added in v1.0.24

func UnReadMailsUID(box string) ([]uint32, error)

返回未读邮件UID

func UnReadMailsUIDByDate added in v1.0.24

func UnReadMailsUIDByDate(box string, since, before time.Time) ([]uint32, error)

获取时间段内所有未读邮件的UID

func UnreadMails added in v1.0.24

func UnreadMails(box string) (int, error)

返回第一封未读邮件的索引

Types

type BaseMail added in v1.0.15

type BaseMail struct {
	// 邮件唯一编号
	ID uint32 `json:"id"`
	// 标题
	Subject string `json:"subject"`
	// 发件人
	FromName string `json:"from_name"`
	// 发件人地址
	// xxx@xxx.xxx
	FromAddr string `json:"from_addr"`
}

func GetBaseMails added in v1.0.24

func GetBaseMails(box string, from, till uint32) ([]BaseMail, error)

获取信封信息

type Client

type Client struct {

	// 当前邮箱中的邮件总数量
	Num   uint32
	Mails chan *Mail
	// contains filtered or unexported fields
}

func (*Client) GetBaseMails added in v1.0.15

func (c *Client) GetBaseMails(box string, from, till uint32) ([]BaseMail, error)

func (*Client) GetCurrentNum added in v1.0.25

func (c *Client) GetCurrentNum() uint32

func (*Client) GetEmailBySubject added in v1.0.18

func (c *Client) GetEmailBySubject(box, keyword string) (*Mail, error)

func (*Client) GetEmailByUID added in v1.0.7

func (c *Client) GetEmailByUID(boxName string, uid uint32) (*Mail, error)

func (*Client) Keepalive added in v1.0.7

func (c *Client) Keepalive()

func (*Client) Logout

func (c *Client) Logout()

func (*Client) Reconnect

func (c *Client) Reconnect() error

func (*Client) SetAnsweredFlag

func (c *Client) SetAnsweredFlag(uid uint32) error

func (*Client) UnReadMailsUID added in v1.0.6

func (c *Client) UnReadMailsUID(box string) ([]uint32, error)

func (*Client) UnReadMailsUIDByDate added in v1.0.24

func (c *Client) UnReadMailsUIDByDate(box string, since, before time.Time) ([]uint32, error)

func (*Client) UnreadMails

func (c *Client) UnreadMails(box string) (int, error)

type Mail

type Mail struct {
	// 邮件基础信息
	BaseMail

	// 邮件正文
	Body string
	// 收件人、抄送人
	To, Cc []string
	// 附件
	Attachments map[string]io.Reader
}

func GetEmailBySubject added in v1.0.24

func GetEmailBySubject(box, keyword string) (*Mail, error)

通过标题搜索并获取邮件 当搜索结果大于1封邮件时, 将会抛出异常

func GetEmailByUID added in v1.0.24

func GetEmailByUID(boxName string, uid uint32) (*Mail, error)

通过UID获取邮件

func NewMailFromMessage

func NewMailFromMessage(msg *imap.Message, section *imap.BodySectionName) (*Mail, error)

Jump to

Keyboard shortcuts

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