Skip to content

Commit 7364bd0

Browse files
committed
tool(email):add 163 mail support
1 parent 37d2b9d commit 7364bd0

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

examples/email/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# email Example
22

3-
This example demonstrates how to handle various types of email (qq,gmail) using OpenAI-compatible models.
3+
This example demonstrates how to handle various types of email (qq,gmail,163) using OpenAI-compatible models.
44

55
## Features
66

tool/email/sendmail.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ import (
1616
)
1717

1818
const (
19-
qqMail = "smtp.qq.com"
20-
qqPort = 465
21-
gmailMail = "smtp.gmail.com"
22-
gmailPort = 587
19+
qqMail = "smtp.qq.com"
20+
qqPort = 465
21+
gmailMail = "smtp.gmail.com"
22+
gmailPort = 587
23+
netEase163Mail = "smtp.163.com"
24+
netEase1163Port = 465
2325
)
2426

2527
// sendMailRequest represents the input for the send mail operation.
@@ -144,6 +146,11 @@ func (e *emailToolSet) getEmailAddr(req *sendMailRequest) (addr string, port int
144146
addr = gmailMail
145147
port = gmailPort
146148
isSSL = false
149+
case MAIL_163:
150+
//163 email
151+
addr = netEase163Mail
152+
port = netEase1163Port
153+
isSSL = true
147154
default:
148155
// not support
149156
err = fmt.Errorf("not support mailbox type:%s", MailboxTypeToString(mailBoxType))

tool/email/sendmail_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func Test_emailToolSet_sendMail(t *testing.T) {
2323
Content string
2424
wantErr bool
2525
}{
26-
26+
// qq to gmail
2727
{
2828
2929
Password: "",
@@ -32,7 +32,7 @@ func Test_emailToolSet_sendMail(t *testing.T) {
3232
Content: "test",
3333
wantErr: false,
3434
},
35-
35+
// gmail to qq
3636
{
3737
3838
Password: "",
@@ -41,6 +41,15 @@ func Test_emailToolSet_sendMail(t *testing.T) {
4141
Content: "test",
4242
wantErr: false,
4343
},
44+
// 163 to gmail
45+
{
46+
47+
Password: "",
48+
ToEmail: "[email protected]",
49+
Subject: "test",
50+
Content: "test",
51+
wantErr: false,
52+
},
4453
}
4554
for _, tt := range tests {
4655

@@ -59,8 +68,7 @@ func Test_emailToolSet_sendMail(t *testing.T) {
5968
})
6069
t.Logf("rsp: %+v err:%v", rsp, err)
6170
if tt.Password == "" {
62-
t.Logf("password is empty, skip")
63-
continue
71+
t.Skip("password is empty, skip")
6472
}
6573
if rsp.Message != "" {
6674
if tt.wantErr == false {

0 commit comments

Comments
 (0)