email

package
v3.0.0-...-3edb00a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: GPL-3.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrChanNotOpen 邮件队列未开启
	ErrChanNotOpen = errors.New("email queue is not started")
	// ErrNoActiveDriver 无可用邮件发送服务
	ErrNoActiveDriver = errors.New("no avaliable email provider")
)

Lock 读写锁

Functions

func Init

func Init()

Init 初始化

func NewActivationEmail

func NewActivationEmail(userName, activateURL string) (string, string)

NewActivationEmail 新建激活邮件

func NewResetEmail

func NewResetEmail(userName, resetURL string) (string, string)

NewResetEmail 新建重设密码邮件

func Send

func Send(to, title, body string) error

Send 发送邮件

Types

type Driver

type Driver interface {
	// Close 关闭驱动
	Close()
	// Send 发送邮件
	Send(to, title, body string) error
}

Driver 邮件发送驱动

var Client Driver

Client 默认的邮件发送客户端

type SMTP

type SMTP struct {
	Config SMTPConfig
	// contains filtered or unexported fields
}

SMTP SMTP协议发送邮件

func NewSMTPClient

func NewSMTPClient(config SMTPConfig) *SMTP

NewSMTPClient 新建SMTP发送队列

func (*SMTP) Close

func (client *SMTP) Close()

Close 关闭发送队列

func (*SMTP) Init

func (client *SMTP) Init()

Init 初始化发送队列

func (*SMTP) Send

func (client *SMTP) Send(to, title, body string) error

Send 发送邮件

type SMTPConfig

type SMTPConfig struct {
	Name       string // 发送者名
	Address    string // 发送者地址
	ReplyTo    string // 回复地址
	Host       string // 服务器主机名
	Port       int    // 服务器端口
	User       string // 用户名
	Password   string // 密码
	Encryption bool   // 是否启用加密
	Keepalive  int    // SMTP 连接保留时长
}

SMTPConfig SMTP发送配置

Jump to

Keyboard shortcuts

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