-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathx.go
More file actions
54 lines (47 loc) · 1.32 KB
/
x.go
File metadata and controls
54 lines (47 loc) · 1.32 KB
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
// Package main :: x.go - examples and tests
// Note: any function in `main` package but not in `main.go` seems invisible by `main()`
package main
import (
"bytes"
"fmt"
"strings"
"github.com/dockerian/go-coding/pkg/msg"
"github.com/dockerian/go-coding/pkg/zip"
)
// ExamplesTest runs any functional test for this project
func ExamplesTest() {
message := msg.Message{
To: []string{"to@mail.com"},
Cc: []string{"cc@mail.com"},
Bcc: []string{"bcc@mail.com"},
Body: []byte("test"),
Subject: "go-coding/pkg/msg test 1",
}
sources := []*zip.Source{
{
Reader: strings.NewReader("attachment test 1"), Name: "test1.txt",
},
{
Reader: strings.NewReader("attachment test 2"), Name: "test2.txt",
},
}
var buffer bytes.Buffer
if err := zip.CreateZip(sources, &buffer); err != nil {
fmt.Println("zip.CreateZip error:", err)
} else {
message.Attach(&buffer, "test.zip", "application/zip")
}
// log.Println("----zip content----:\n", string(buffer.Bytes()))
message.From = "threatintelligence@infoblox.com"
sender := msg.MessageSender{
Message: message,
DomainName: "gmail.com",
ServerHost: "smtp.office365.com",
ServerPort: 587,
UserName: "dockeria@gmail.com",
Password: "password",
WithTLS: true,
}
fmt.Printf("sending mail by %+v\n", sender)
fmt.Println(sender.Send())
}