app/email/service.go

32 lines
642 B
Go
Raw Normal View History

2021-12-17 04:54:03 +00:00
package email
2021-12-17 03:46:04 +00:00
import (
"fmt"
"time"
"github.com/spf13/viper"
2021-12-17 04:54:03 +00:00
"gopkg.in/gomail.v2"
2021-12-17 03:46:04 +00:00
"kumoly.io/kumoly/app/system"
)
2021-12-17 04:54:03 +00:00
type Service struct {
2021-12-17 03:46:04 +00:00
system.BaseService
}
2021-12-17 04:54:03 +00:00
func (srv Service) GetName() string { return "email.Service" }
2021-12-17 03:46:04 +00:00
2021-12-17 04:54:03 +00:00
func (srv *Service) Init() error {
2021-12-17 03:46:04 +00:00
app.Name = viper.GetString("name")
app.Copyright = fmt.Sprintf("Copyright © %v %s. All rights reserved.",
time.Now().Year(), viper.GetString("name"))
app.Link = viper.GetString("server.url")
2021-12-17 04:54:03 +00:00
dial = gomail.NewDialer(
viper.GetString("email.host"),
viper.GetInt("email.port"),
viper.GetString("email.username"),
viper.GetString("email.password"))
2021-12-17 03:46:04 +00:00
return nil
}