61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
package email
 | 
						||
 | 
						||
import (
 | 
						||
	"fmt"
 | 
						||
	"time"
 | 
						||
 | 
						||
	"github.com/spf13/viper"
 | 
						||
	"gopkg.in/gomail.v2"
 | 
						||
	"kumoly.io/kumoly/app/system"
 | 
						||
)
 | 
						||
 | 
						||
type Service struct {
 | 
						||
	system.BaseService
 | 
						||
}
 | 
						||
 | 
						||
func (srv Service) GetName() string { return "email.Service" }
 | 
						||
 | 
						||
func (srv *Service) Init() error {
 | 
						||
	app.Name = viper.GetString("name")
 | 
						||
	app.Copyright = fmt.Sprintf("Copyright © %v %s. All rights reserved.",
 | 
						||
		time.Now().Year(), app.Name)
 | 
						||
	app.Link = viper.GetString("server.url")
 | 
						||
	app.Logo = viper.GetString("logo")
 | 
						||
	app.Theme = viper.GetString("email.theme")
 | 
						||
	app.TitleColor = "#2F3133"
 | 
						||
	app.FooterColor = "#AEAEAE"
 | 
						||
 | 
						||
	dial = DefaultDailer()
 | 
						||
 | 
						||
	return nil
 | 
						||
}
 | 
						||
 | 
						||
func DefaultDailer() *gomail.Dialer {
 | 
						||
	return gomail.NewDialer(
 | 
						||
		viper.GetString("email.host"),
 | 
						||
		viper.GetInt("email.port"),
 | 
						||
		viper.GetString("email.username"),
 | 
						||
		viper.GetString("email.password"))
 | 
						||
}
 | 
						||
 | 
						||
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"
 | 
						||
	app.TroubleText = "If you’re having trouble with the button '{ACTION}', copy and paste the URL below into your web browser."
 | 
						||
	app.Theme = "#F2F4F6"
 | 
						||
	app.TitleColor = "#2F3133"
 | 
						||
	app.FooterColor = "#AEAEAE"
 | 
						||
	dial = gomail.NewDialer("mail.kumoly.io", 587, "test@kumoly.io", "test")
 | 
						||
}
 | 
						||
 | 
						||
func SetDefault(a App) {
 | 
						||
	app = a
 | 
						||
}
 | 
						||
 | 
						||
func SetDailer(d *gomail.Dialer) {
 | 
						||
	dial = d
 | 
						||
}
 |