email_test.go
826 字节
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
package goemail
import (
"testing"
)
const (
testTo1 = ""
testTo2 = "to2@example.com"
testFrom = ""
testpwd = ""
testBody = "Test message"
testMsg = "To: " + testTo1 + ", " + testTo2 + "\r\n" +
"From: " + testFrom + "\r\n" +
"Mime-Version: 1.0\r\n" +
"Date: Wed, 25 Jun 2014 17:46:00 +0000\r\n" +
"Content-Type: text/plain; charset=UTF-8\r\n" +
"Content-Transfer-Encoding: quoted-printable\r\n" +
"\r\n" +
testBody
)
func TestSend(T *testing.T) {
m := &EmailMessage{
FromEmail: testFrom,
Toers: []string{testTo1},
Subject: "测试邮件",
BodyContentType: "text/html",
Body: []byte(testBody),
}
auth := NewLoginAuth(testFrom, testpwd, "smtp.163.com")
err := Send("smtp.163.com:25", auth, m)
if err != nil {
//T.Error(err)
}
// mail.Message{}
}