-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwelcome.go
55 lines (50 loc) · 932 Bytes
/
welcome.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package mails
import (
"bytes"
"fmt"
"github.com/alecthomas/template"
"github.com/jordan-wright/email"
)
/**
* Welcome
*
* struct
*/
type Welcome struct {
Type string
Context email.Email
}
/**
* NewWelcome
*
* @return *UserWelcome
*/
func NewWelcome(context email.Email) Welcome {
return Welcome{
Type: "-",
Context: context,
}
}
/**
* Render
*
* @return infrastructures.IEmailService
*/
func (w Welcome) Render(data map[string]interface{}, to []string) (context email.Email, err error) {
var t *template.Template
t, err = template.ParseFiles("views/welcome.html")
if err != nil {
return email.Email{}, err
}
var body bytes.Buffer
err = t.Execute(&body, struct {
Url interface{}
}{
Url: data["url"],
})
w.Context.From = "Gotham <[email protected]>"
w.Context.To = to
w.Context.Subject = fmt.Sprintf("Welcome to Gotham")
w.Context.HTML = body.Bytes()
return w.Context, err
}