作者 yangfu

邮件发送 common/mail.go

@@ -9,7 +9,32 @@ import ( @@ -9,7 +9,32 @@ import (
9 "net" 9 "net"
10 "net/smtp" 10 "net/smtp"
11 ) 11 )
  12 +/*
  13 +用途 发送邮件
  14 +1.初始化
  15 +InitMailService(&MailConfig{
  16 + Host:"smtp.qq.com",
  17 + Port:25,
  18 + From:"785410885@qq.com",
  19 + Password:"ibfduqhfmgypbffe", //授权码
  20 + IsUseSsl:false,
  21 + })
  22 +或者
  23 +InitMailService(&MailConfig{
  24 + Host:"smtp.qq.com",
  25 + Port:465,
  26 + From:"785410885@qq.com",
  27 + Password:"ibfduqhfmgypbffe", //授权码
  28 + IsUseSsl:true,
  29 + })
12 30
  31 +2.发送邮件
  32 +SendMail(&MailContent{
  33 + ToMail:"892423867@qq.com",
  34 + Subject:"测试邮件",
  35 + Body:[]byte("邮件内容..."),
  36 + })
  37 + */
13 var( 38 var(
14 ErrorInvalidMailConfig = fmt.Errorf("mail config error") 39 ErrorInvalidMailConfig = fmt.Errorf("mail config error")
15 ) 40 )
@@ -15,4 +15,6 @@ func NewBeeormEngine(conf config.Mysql){ @@ -15,4 +15,6 @@ func NewBeeormEngine(conf config.Mysql){
15 } 15 }
16 orm.SetMaxIdleConns("default", conf.MaxIdle) 16 orm.SetMaxIdleConns("default", conf.MaxIdle)
17 orm.SetMaxOpenConns("default", conf.MaxOpen) 17 orm.SetMaxOpenConns("default", conf.MaxOpen)
  18 + //orm.DefaultTimeLoc = time.Local
  19 + //orm.Debug = true
18 } 20 }