app/email/service.go

41 lines
970 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.",
2021-12-17 06:18:31 +00:00
time.Now().Year(), app.Name)
2021-12-17 03:46:04 +00:00
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
}
2021-12-17 06:18:31 +00:00
func setupDefault() {
app.Name = "Kumoly Test"
app.Copyright = fmt.Sprintf("Copyright © %v %s. All rights reserved.",
time.Now().Year(), app.Name)
app.Link = "https://kumoly.io"
app.Logo = "http://www.duchess-france.org/wp-content/uploads/2016/01/gopher.png"
dial = gomail.NewDialer("mail.kumoly.io", 587, "test@kumoly.io", "test")
}