zdpgo_smtp

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: MIT Imports: 17 Imported by: 0

README

zdpgo_smtp

smtp服务和客户端实现

版本历史

  • v0.1.1 新增:SMTP服务和客户端

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
}

type Backend

type Backend struct {
}

Backend 后台实现

func (*Backend) NewSession

func (bkd *Backend) NewSession(c smtp.ConnectionState) (smtp.Session, error)

type CacheConfig

type CacheConfig struct {
	Host string `yaml:"host" json:"host"`
	Port int    `yaml:"port" json:"port"`
}

type Client

type Client struct {
	Config *Config
	Email  *zdpgo_email.Email
	Cache  *zdpgo_cache_http.Client
}

func (*Client) GetMd5

func (c *Client) GetMd5(data []byte) string

GetMd5 获取数据的MD5值

func (*Client) UploadAndCheckMd5

func (c *Client) UploadAndCheckMd5(filePath string) bool

UploadAndCheckMd5 上传文件并检查MD5

type ClientConfig

type ClientConfig struct {
	Email    string      `yaml:"email" json:"email"`
	Username string      `yaml:"username" json:"username"`
	Password string      `yaml:"password" json:"password"`
	Host     string      `yaml:"host" json:"host"`
	Port     int         `yaml:"port" json:"port"`
	Cache    CacheConfig `yaml:"cache" json:"cache"`
}

type Config

type Config struct {
	Debug       bool            `yaml:"debug" json:"debug"`
	LogFilePath string          `yaml:"log_file_path" json:"log_file_path"`
	Domain      string          `yaml:"domain" json:"domain"`
	Host        string          `yaml:"host" json:"host"`
	Port        int             `yaml:"port" json:"port"`
	Auths       map[string]Auth `yaml:"auths" json:"auths"`
	Cache       CacheConfig     `yaml:"cache" json:"cache"`
	Client      ClientConfig    `yaml:"client" json:"client"`
}

type Message

type Message struct {
	From        string            `json:"from"`
	To          []string          `json:"to"`
	Subject     string            `json:"subject"`
	Body        string            `json:"body"`
	Time        int               `json:"time"`
	Author      string            `json:"author"`      // zdpgo_email发过来的唯一标识
	Attachments map[string]string `json:"attachments"` // 文件名:文件内容的base64字符串
}

func (*Message) ParseFileContent

func (m *Message) ParseFileContent(dataStr string) ([]byte, error)

ParseFileContent 解析文件内容

func (*Message) ParseFileName

func (m *Message) ParseFileName(dataStr string) (string, error)

ParseFileName 解析文件名

func (*Message) ParseString

func (m *Message) ParseString(data string) error

ParseString 解析字符串

func (*Message) ParseTitle

func (m *Message) ParseTitle(title string) (string, error)

ParseTitle 解析邮件标题

type ServerInfo

type ServerInfo struct {
	Domain string `yaml:"domain" json:"domain"`
	Host   string `yaml:"host" json:"host"`
	Port   int    `yaml:"port" json:"port"`
}

type Session

type Session struct {
}

Session 会话实现

func (*Session) AuthPlain

func (s *Session) AuthPlain(username, password string) error

AuthPlain 用户名和密码校验

func (*Session) Data

func (s *Session) Data(r io.Reader) error

func (*Session) GetMd5

func (s *Session) GetMd5(data []byte) string

GetMd5 获取数据的MD5值

func (*Session) Logout

func (s *Session) Logout() error

func (*Session) Mail

func (s *Session) Mail(from string, opts *smtp.MailOptions) error

func (*Session) Rcpt

func (s *Session) Rcpt(to string) error

func (*Session) Reset

func (s *Session) Reset()

type Smtp

type Smtp struct {
	Config *Config
	Server *smtp.Server
	Cache  *zdpgo_cache_http.Client
}

func New

func New() *Smtp

func NewWitchConfig

func NewWitchConfig(config *Config) *Smtp

func (*Smtp) GetCacheClient

func (s *Smtp) GetCacheClient() *zdpgo_cache_http.Client

GetCacheClient 获取缓存客户端对象

func (*Smtp) GetClient

func (s *Smtp) GetClient() (*Client, error)

GetClient 获取客户端

func (*Smtp) Run

func (s *Smtp) Run() error

func (*Smtp) RunCache

func (s *Smtp) RunCache() error

RunCache 运行缓存服务

Directories

Path Synopsis
example
Library for Simple Authentication and Security Layer (SASL) defined in RFC 4422.
Library for Simple Authentication and Security Layer (SASL) defined in RFC 4422.

Jump to

Keyboard shortcuts

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