email

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDialer

func GetDialer() *ge.Dialer

GetDialer 在使用 InitSMTPDialer 初始化内部私有 dialer 后,可以使用该函数获取此 dialer 的指针

func Init

func Init(host, username, password string, port int) *ge.Dialer

Init 同 gomail.NewDialer

func InitSMTPDialer

func InitSMTPDialer(host, username, password string, port int)

InitSMTPDialer 会初始化一个私有的 dialer, 以后可以使用 Send 方法时会使用这个内部的私有 dialer 对象, 该方法适用于一个程序中只需要一个 SMTP dialer 的情况,如果 需要多个 dialer 对象,请使用 Init 和 SendWithDialer 方法

func Send

func Send(c *Context) (err error)

Send 配合 InitSMTPDialer 使用

func SendWithDialer

func SendWithDialer(dia *ge.Dialer, c *Context) (err error)

SendWithDialer 使用自定义的 dialer 发送邮件

Types

type Context

type Context struct {
	ToList  []Role `json:"to_list"`  // 收件人列表
	CcList  []Role `json:"cc_list"`  // 抄送列表
	BccList []Role `json:"bcc_list"` // 密送列表
	Subject string `json:"subject"`  // 邮件主题
	Body    string `json:"body"`     // 邮件正文
	Path    string `json:"path"`     // 附件路径
}

type Role

type Role struct {
	Name    string `json:"name"`
	Address string `json:"address"`
}

type SMTPDialer

type SMTPDialer struct {
	Host     string `ini:"host"`
	Port     int    `ini:"port"`
	Username string `ini:"username"`
	Password string `ini:"password"`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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