23 lines
513 B
Go
23 lines
513 B
Go
|
package renderer
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"git.coopgo.io/coopgo-platform/emailing"
|
||
|
"github.com/spf13/viper"
|
||
|
)
|
||
|
|
||
|
func NewEmailingHandler(cfg *viper.Viper) (*emailing.Mailer, error) {
|
||
|
templates_dir := cfg.GetString("templates.root")
|
||
|
|
||
|
theme := viper.New()
|
||
|
theme.SetConfigName("config")
|
||
|
theme.AddConfigPath(templates_dir)
|
||
|
err := theme.ReadInConfig()
|
||
|
if err != nil {
|
||
|
panic(fmt.Errorf("fatal error config file: %w", err))
|
||
|
}
|
||
|
|
||
|
return emailing.NewMailer(templates_dir, theme.Sub("emails"), cfg.Sub("emailing.smtp"))
|
||
|
}
|