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 08:22:04 +00:00
|
|
|
|
app.Logo = viper.GetString("logo")
|
2021-12-17 04:54:03 +00:00
|
|
|
|
|
2021-12-28 18:17:44 +00:00
|
|
|
|
dial = DefaultDailer()
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func DefaultDailer() *gomail.Dialer {
|
|
|
|
|
return gomail.NewDialer(
|
2021-12-17 04:54:03 +00:00
|
|
|
|
viper.GetString("email.host"),
|
|
|
|
|
viper.GetInt("email.port"),
|
|
|
|
|
viper.GetString("email.username"),
|
|
|
|
|
viper.GetString("email.password"))
|
2021-12-17 03:46:04 +00:00
|
|
|
|
}
|
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"
|
2021-12-24 19:31:53 +00:00
|
|
|
|
app.TroubleText = "If you’re having trouble with the button '{ACTION}', copy and paste the URL below into your web browser."
|
2021-12-17 06:18:31 +00:00
|
|
|
|
dial = gomail.NewDialer("mail.kumoly.io", 587, "test@kumoly.io", "test")
|
|
|
|
|
}
|
2021-12-28 18:17:44 +00:00
|
|
|
|
|
|
|
|
|
func SetDefault(a App) {
|
|
|
|
|
app = a
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func SetDailer(d *gomail.Dialer) {
|
|
|
|
|
dial = d
|
|
|
|
|
}
|