feat:完善信息
This commit is contained in:
20
lib/email.go
20
lib/email.go
@ -9,11 +9,15 @@ type Email struct {
|
||||
}
|
||||
|
||||
type EmailOption struct {
|
||||
User, Auth string // Auth:定义邮箱服务器连接信息,如果是阿里邮箱 Auth填密码,qq邮箱填授权码
|
||||
Host string
|
||||
Port int
|
||||
Alias, User, Pass string // Auth:定义邮箱服务器连接信息,如果是阿里邮箱 Pass填密码,qq邮箱填授权码
|
||||
Host string
|
||||
Port int
|
||||
}
|
||||
|
||||
// EmailSendHandle 邮件发送处理
|
||||
// @objects:发送对象,多个邮件地址
|
||||
// @subject:邮件主题
|
||||
// @body:邮件正文
|
||||
type EmailSendHandle func(objects []string, subject, body string) error
|
||||
|
||||
func (this *Email) Init() {
|
||||
@ -23,11 +27,11 @@ func (this *Email) Init() {
|
||||
func (this *Email) Send() EmailSendHandle {
|
||||
return func(objects []string, subject, body string) error {
|
||||
m := gomail.NewMessage()
|
||||
m.SetHeader("From", "XD Game"+"<"+this.User+">") //这种方式可以添加别名,即“XD Game”, 也可以直接用<code>m.SetHeader("From",mailConn["user"])</code> 读者可以自行实验下效果
|
||||
m.SetHeader("To", objects...) //发送给多个用户
|
||||
m.SetHeader("Subject", subject) //设置邮件主题
|
||||
m.SetBody("text/html", body) //设置邮件正文
|
||||
return gomail.NewDialer(this.Host, this.Port, this.User, this.Auth).DialAndSend(m)
|
||||
m.SetHeader("From", m.FormatAddress(this.User, this.Alias))
|
||||
m.SetHeader("To", objects...)
|
||||
m.SetHeader("Subject", subject)
|
||||
m.SetBody("text/html", body)
|
||||
return gomail.NewDialer(this.Host, this.Port, this.User, this.Pass).DialAndSend(m)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user