-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail_message_test.go
57 lines (51 loc) · 1.25 KB
/
mail_message_test.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
56
57
package delayed_job
import (
"net/mail"
"strings"
"testing"
"github.com/runner-mei/delayed_job/smtp"
)
func TestMailMessageTextAndHtml(t *testing.T) {
if "" == *defaultSmtpServer {
t.Skip("please set 'test.mail_to', 'mail.from' and 'mail.smtp_server'")
return
}
msg := &MailMessage{
From: mail.Address{
Name: "发件人的名字",
Address: *default_mail_address}, // if From.Address is empty, Config.DefaultFrom will be used
To: []*mail.Address{&mail.Address{
Name: "收件人的名字",
Address: *test_mail_to}},
Subject: "这是一个 增 消息",
ContentText: "这是一个Text消息",
ContentHtml: `<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
这是一个 Html 消息
</body>
</html>
`,
Attachments: []Attachment{
{Name: "中文名的附件.txt", Content: strings.NewReader("aaaaaoooo")},
}}
// bs, e := msg.Bytes()
// if nil != e {
// t.Error(e)
// return
// }
// t.Log(string(bs))
if e := msg.Send(*defaultSmtpServer, smtp.PlainAuth(*default_mail_auth_identity,
*default_mail_address,
*default_mail_auth_password,
*default_mail_auth_host,
tryNTLM),
useTls(),
*default_mail_useFQDN); nil != e {
t.Error(e)
}
}