zdpgo_imap

package module
v0.0.0-...-8b64b0f Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: MIT Imports: 10 Imported by: 0

README

zdpgo_imap

处理imap邮件协议

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Debug       bool   `json:"debug"`
	LogFilePath string `json:"log_file_path"`
	Username    string `json:"username"`
	Password    string `json:"password"`
	Host        string `json:"host"`
	Port        int    `json:"port"`
	TmpDir      string `json:"tmp_dir"`
}

type Imap

type Imap struct {
	Config         *Config
	Result         *Result
	Results        []*Result
	All            []*Result // 存储所有的邮件
	LastSearchTime time.Time // 最近一次搜索
	Client         *client.Client
	Log            *zdpgo_log.Log
}

func New

func New() *Imap

func NewWithConfig

func NewWithConfig(config *Config) *Imap

func (*Imap) GetBasicResult

func (i *Imap) GetBasicResult(message *imap.Message) *Result

GetBasicResult 获取基本结果信息

func (*Imap) GetResult

func (i *Imap) GetResult(message *imap.Message,
	mailReader *mail.Reader) (*Result, error)

GetResult 获取查询结果

func (*Imap) InitClient

func (i *Imap) InitClient()

func (*Imap) IsHealth

func (i *Imap) IsHealth() bool

func (*Imap) SearchByContent

func (i *Imap) SearchByContent(searchContent string) ([]*Result, error)

SearchByContent 根据内容搜索

func (*Imap) SearchByRecent

func (i *Imap) SearchByRecent(recentNum uint32) ([]*Result, error)

搜索最近的指定数量的邮件

func (*Imap) SearchByTitle

func (i *Imap) SearchByTitle(title string) ([]*Result, error)

SearchByTitle 根据邮件标题查询邮件 【处理业务需求】假设需求是找出求以subject开头的标题的最新邮件,并下载附件。 【思路】有些邮件包含附件后会变得特别大,如果要遍历的邮件很多,直接遍历处理,每封邮件都获取'RFC822'内容, fetch方法执行耗时可能会很长, 因此可以分两次fetch处理,减少处理时长: 1)第一次fetch先使用ENVELOP或者RFC822.HEADER获取邮件头信息找到满足业务需求邮件的id 2)第二次fetch根据这个邮件id使用'RFC822'获取邮件MIME内容,下载附件

type Result

type Result struct {
	From        string              `json:"from"`
	ToEmails    []string            `json:"to_emails"`
	CcEmails    []string            `json:"cc_emails"`
	BccEmails   []string            `json:"bcc_emails"`
	Date        int                 `json:"date"`
	DateStr     string              `json:"date_str"`
	DateTime    time.Time           `json:"date_time"`
	Key         string              `json:"key"`
	Title       string              `json:"title"`
	Body        string              `json:"body"`
	Attachments []map[string][]byte `json:"attachments"`
	Size        uint32              `json:"size"`
	Flags       []string            `json:"flags"`
	SeqNum      uint32              `json:"seq_num"`
}

Directories

Path Synopsis
Package imap implements IMAP4rev1 (RFC 3501).
Package imap implements IMAP4rev1 (RFC 3501).
backend
Package backend defines an IMAP server backend interface.
Package backend defines an IMAP server backend interface.
backend/backendutil
Package backendutil provides utility functions to implement IMAP backends.
Package backendutil provides utility functions to implement IMAP backends.
backend/memory
A memory backend.
A memory backend.
client
Package client provides an IMAP client.
Package client provides an IMAP client.
commands
Package commands implements IMAP commands defined in RFC 3501.
Package commands implements IMAP commands defined in RFC 3501.
responses
IMAP responses defined in RFC 3501.
IMAP responses defined in RFC 3501.
server
Package server provides an IMAP server.
Package server provides an IMAP server.
utf7
Package utf7 implements modified UTF-7 encoding defined in RFC 3501 section 5.1.3
Package utf7 implements modified UTF-7 encoding defined in RFC 3501 section 5.1.3

Jump to

Keyboard shortcuts

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