diff --git a/email/base.gohtml b/email/base.gohtml index 7c68eb1..bbc0e99 100644 --- a/email/base.gohtml +++ b/email/base.gohtml @@ -284,7 +284,7 @@ -

{{if .Greeting}}{{.Greeting}}{{else}}Hi{{end}} {{ .Receiver }},

+ {{if .Greeting}}

{{.Greeting}} {{ .Receiver }},

{{end}} {{/* Intros */}} {{ with .Intros }} {{ if gt (len .) 0 }} @@ -310,7 +310,7 @@ {{/* End Email */}}

- {{.Signature}}, + {{if .Signature}}{{.Signature}}{{else}}Best Regards{{end}},
{{ if .Sender }}{{.Sender}}{{else}}{{.App.Name}}{{end}}

diff --git a/email/email_test.go b/email/email_test.go index 45d12f0..b72c28f 100644 --- a/email/email_test.go +++ b/email/email_test.go @@ -4,15 +4,27 @@ import ( "testing" ) -func TestSend(t *testing.T) { - (&Service{}).Init() +func TestSendSimple(t *testing.T) { + setupDefault() err := Send("test@kumoly.io", - []string{"evanchen333@gmail.com"}, "Test Mail 2", + []string{"test@kumoly.io"}, "TestSendSimple", &Body{ - Greeting: "歡迎", - Signature: "Best Regards", - Intros: []string{"testing 1.", "loramipsum...."}, - Outros: []string{"testing 2,", "blah blah blah..."}, + Content: `Testing`, + }, + ) + if err != nil { + t.Error(err) + } +} + +func TestSend(t *testing.T) { + setupDefault() + err := Send("test@kumoly.io", + []string{"test@kumoly.io"}, "TestSend", + &Body{ + Greeting: "歡迎", + Intros: []string{"testing 1.", "loramipsum...."}, + Outros: []string{"testing 2,", "blah blah blah..."}, Content: ` # Testing @@ -27,3 +39,29 @@ test|| t.Error(err) } } +func TestMaintain(t *testing.T) { + setupDefault() + err := Send("test@kumoly.io", + []string{"test@kumoly.io"}, "TestMaintain", + &Body{ + Greeting: "您好", + Receiver: "管理員", + Sender: "App System", + Content: ` +> _Hermes_ service will shutdown the **1st August 2017** for maintenance operations. + +Services will be unavailable based on the following schedule: +| Services | Downtime | +| :------:| :-----------: | +| Service A | 2AM to 3AM | +| Service B | 4AM to 5AM | +| Service C | 5AM to 6AM | + +Feel free to contact us for any question regarding this matter at [support@hermes-example.com](mailto:support@hermes-example.com) or in our [Gitter](https://gitter.im/) +`, + }, + ) + if err != nil { + t.Error(err) + } +} diff --git a/email/service.go b/email/service.go index 669a4b3..6c07d89 100644 --- a/email/service.go +++ b/email/service.go @@ -18,7 +18,7 @@ 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(), viper.GetString("name")) + time.Now().Year(), app.Name) app.Link = viper.GetString("server.url") dial = gomail.NewDialer( @@ -29,3 +29,12 @@ func (srv *Service) Init() error { return nil } + +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") +}