email

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrChanNotOpen 邮件队列没有开启
	ErrChanNotOpen = errors.New("email queue does not open")
)

Lock 读写锁

Functions

func Init

func Init(cfg Config)

Init 初始化客户端

func NewActivationEmail

func NewActivationEmail(username, activateURL string) (subject string, body string)

NewActivationEmail 发送激活邮件

func NewActivationHTMLEmail

func NewActivationHTMLEmail(username, activateURL string) (subject string, body string)

NewActivationHTMLEmail 发送激活邮件 html

func NewResetPasswordEmail

func NewResetPasswordEmail(username, resetURL string) (subject string, body string)

NewResetPasswordEmail 发送重置密码邮件

func NewResetPasswordHTMLEmail

func NewResetPasswordHTMLEmail(username, resetURL string) (subject string, body string)

NewResetPasswordHTMLEmail 发送重置密码邮件 html

func Send

func Send(to, subject, body string) error

Send 发送邮件

Types

type ActiveUserMailData

type ActiveUserMailData struct {
	HomeURL       string `json:"home_url"`
	WebsiteName   string `json:"website_name"`
	WebsiteDomain string `json:"website_domain"`
	ActivateURL   string `json:"activate_url"`
	Year          int    `json:"year"`
}

ActiveUserMailData 激活用户模板数据

type Config

type Config struct {
	Host      string
	Port      int
	Username  string
	Password  string
	Name      string
	Address   string
	ReplyTo   string
	KeepAlive int
}

Config email config

type Driver

type Driver interface {
	// Send 发送邮件
	Send(to, subject, body string) error
	// Close 关闭链接
	Close()
}

Driver 邮件发送驱动接口定义

var Client Driver

Client 邮件发送客户端

type ResetPasswordMailData

type ResetPasswordMailData struct {
	HomeURL       string `json:"home_url"`
	WebsiteName   string `json:"website_name"`
	WebsiteDomain string `json:"website_domain"`
	ResetURL      string `json:"reset_url"`
	Year          int    `json:"year"`
}

ResetPasswordMailData 激活用户模板数据

type SMTP

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

SMTP 协议协议发送

func NewSMTPClient

func NewSMTPClient(config SMTPConfig) *SMTP

NewSMTPClient 实例化一个SMTP客户端

func (*SMTP) Close

func (c *SMTP) Close()

Close 关闭队列

func (*SMTP) Init

func (c *SMTP) Init()

Init 初始化发送队列

func (*SMTP) Send

func (c *SMTP) Send(to, subject, body string) error

Send 发送邮件

type SMTPConfig

type SMTPConfig struct {
	Name      string // 发送者名称
	Address   string // 发送者地址
	ReplyTo   string // 回复地址
	Host      string // 服务器主机名
	Port      int    // 服务器端口
	Username  string // 用户名
	Password  string // 密码
	Keepalive int    // 连接保活时长, 单位秒
}

SMTPConfig SMTP配置

Jump to

Keyboard shortcuts

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