-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTemplate.go
40 lines (33 loc) · 943 Bytes
/
Template.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
package main
import (
"context"
"time"
"github.com/crossphoton/email-microservice/examples/src"
)
func sendEmailWithTemplate(req *src.SendEmailWithTemplateRequest) (*src.ResponseMessage, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
res, err := client.SendEmailWithTemplate(ctx, req)
if err != nil {
return nil, err
}
return res, nil
}
func TemplateEmail() (*src.ResponseMessage, error) {
// Template request
emailRequest := src.SendEmailWithTemplateRequest{
Recipients: &src.Recipients{
To: []string{
"Aditya Agrawal<adiag1200@gmail.com>",
},
},
TemplateName: "email-confirm",
TemplateParams: map[string]string{
"UserName": "Aditya Agrawal",
"ConfirmAccountLink": "https://google.com",
"UnsubscribeLink": "https://google.com/unsubscribe",
},
Subject: "This is from a template",
}
return sendEmailWithTemplate(&emailRequest)
}