-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail.go
43 lines (36 loc) · 1.02 KB
/
email.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
// Copyright 2022 FishGoddess. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package main
import (
"context"
"fmt"
"github.com/infro-io/postar-client/postar"
)
func main() {
// You can use NewGrpcEmailService to create a grpc client for sending emails.
// Change it to NewHttpEmailService so you can create a http client, but notice the ip:port!
//emailService, err := postar.NewHttpEmailService("127.0.0.1:6897", 100, "")
emailService, err := postar.NewGrpcEmailService("127.0.0.1:5897", 100, "")
if err != nil {
panic(err)
}
ctx := context.Background()
email := &postar.Email{
TemplateID: 1000001,
To: []string{"[email protected]"},
SubjectParams: map[string]string{
"num": "123",
"subject": "测试客户端",
},
ContentParams: map[string]string{
"p": "grpc",
"img": "-",
},
}
result, err := emailService.SendEmail(ctx, email)
if err != nil {
panic(err)
}
fmt.Println("trace id:", result.TraceID)
}