email

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client 客户端

func New

func New(conf Conf) *Client

New 新建smtp实例

func (*Client) SendMailWithTLS

func (c *Client) SendMailWithTLS(to []string, msg []byte) error

SendMailWithTLS 使用tls方式发送

type Conf

type Conf struct {
	Workers               int    `yaml:"workers" toml:"workers" json:"workers"`                                                 //协程数量
	WorkerThrottleSeconds int    `yaml:"worker_throttle_seconds" toml:"worker_throttle_seconds" json:"worker_throttle_seconds"` //每个协程内发送间隔,单位秒
	Host                  string `yaml:"host" toml:"host" json:"host"`                                                          //邮件服务器域名
	Port                  int    `yaml:"port" toml:"port" json:"port"`                                                          //邮件服务器端口
	Username              string `yaml:"username" toml:"username" json:"username"`                                              //邮件服务登录账号
	Password              string `yaml:"password" toml:"password" json:"password"`                                              //邮件服务登录密码
	From                  string `yaml:"from" toml:"from" json:"from"`                                                          //发送人邮箱
	Subject               string `yaml:"subject" toml:"subject" json:"subject"`                                                 //邮件主题
	Params                struct {
		Variables []string `yaml:"variables" toml:"variables" json:"variables"` //替换变量
	} `yaml:"params" toml:"params" json:"params"` //其他参数
}

Conf 配置

<yaml example>

email:

workers:
work_throttle_seconds: 5
host:
port:
username:
password:
from:
subject:
params:
	variables:

<toml example>

email

workers =

work_throttle_seconds = 5

host =

port =

username =

password =

from =

subject =

[email.params]

variables =

type Envelope

type Envelope struct {
	From     string                       //发送人邮箱
	To       string                       //收件人邮件
	Subject  string                       //主题
	MimeType string                       //邮件类型
	Body     string                       //邮件内容
	Callback func(e *Envelope, err error) //回调函数
}

Envelope 信封

type Pool

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

Pool 发送池

func NewPool

func NewPool(conf Conf) *Pool

NewPool 实例化

func (*Pool) Done

func (p *Pool) Done()

Done 发送完成

func (*Pool) Emit

func (p *Pool) Emit()

Emit 启动队列

func (*Pool) Mount

func (p *Pool) Mount(index int, envelope *Envelope)

Mount 加入发送队列

Jump to

Keyboard shortcuts

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