mindoc/conf/mail.go

45 lines
1.1 KiB
Go
Raw Normal View History

2017-05-03 14:22:05 +08:00
package conf
import (
"github.com/astaxie/beego"
"strings"
)
type SmtpConf struct {
EnableMail bool
MailNumber int
2017-05-03 14:22:05 +08:00
SmtpUserName string
SmtpHost string
2017-05-03 14:22:05 +08:00
SmtpPassword string
SmtpPort int
2017-05-03 14:22:05 +08:00
FormUserName string
MailExpired int
2018-02-02 18:41:27 +08:00
Secure string
2017-05-03 14:22:05 +08:00
}
func GetMailConfig() *SmtpConf {
user_name := beego.AppConfig.String("smtp_user_name")
password := beego.AppConfig.String("smtp_password")
smtp_host := beego.AppConfig.String("smtp_host")
smtp_port := beego.AppConfig.DefaultInt("smtp_port", 25)
2017-05-03 14:22:05 +08:00
form_user_name := beego.AppConfig.String("form_user_name")
enable_mail := beego.AppConfig.String("enable_mail")
mail_number := beego.AppConfig.DefaultInt("mail_number", 5)
2018-02-02 18:41:27 +08:00
secure := beego.AppConfig.DefaultString("secure","NONE")
2017-05-03 14:22:05 +08:00
2018-02-02 18:41:27 +08:00
if secure != "NONE" && secure != "LOGIN" && secure != "SSL" {
secure = "NONE"
}
2017-05-03 14:22:05 +08:00
c := &SmtpConf{
EnableMail: strings.EqualFold(enable_mail, "true"),
MailNumber: mail_number,
SmtpUserName: user_name,
SmtpHost: smtp_host,
SmtpPassword: password,
FormUserName: form_user_name,
SmtpPort: smtp_port,
2018-02-02 18:41:27 +08:00
Secure:secure,
2017-05-03 14:22:05 +08:00
}
return c
}