smtp支持ssl
This commit is contained in:
+31
-17
@@ -3,8 +3,6 @@ package smtp_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"code.yun.ink/pkg/mailx/interfaces"
|
||||
@@ -15,35 +13,51 @@ func TestMail(t *testing.T) {
|
||||
sm := smtp.NewSmtp()
|
||||
ctx := context.Background()
|
||||
|
||||
// ini, err := sm.SetOption(ctx, interfaces.SetSmtp(&interfaces.EmailConfigDataSmtp{
|
||||
// Username: "support@email.blueoceanpay.com",
|
||||
// Password: "SupporT2017",
|
||||
// ReplyTo: "",
|
||||
// Host: "smtpdm-ap-southeast-1.aliyun.com",
|
||||
// Port: "80",
|
||||
// }))
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
|
||||
|
||||
ini, err := sm.SetOption(ctx, interfaces.SetSmtp(&interfaces.EmailConfigDataSmtp{
|
||||
Username: "support@email.blueoceanpay.com",
|
||||
Password: "SupporT2017",
|
||||
IsSSL: true,
|
||||
Username: "demo@yunink.net",
|
||||
Password: "aAhVPzHydLoc9Fj8",
|
||||
ReplyTo: "",
|
||||
Host: "smtpdm-ap-southeast-1.aliyun.com",
|
||||
Port: "80",
|
||||
Host: "smtp.exmail.qq.com",
|
||||
Port: "465",
|
||||
}))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
req, err := http.Get("https://baidu.com")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer req.Body.Close()
|
||||
|
||||
by, err := io.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// req, err := http.Get("https://baidu.com")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// defer req.Body.Close()
|
||||
|
||||
// by, err := io.ReadAll(req.Body)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
|
||||
msg := interfaces.Message{
|
||||
Form: "demo@yunink.net",
|
||||
To: []string{"995116474@qq.com"},
|
||||
Cc: []string{"287852692@qq.com"},
|
||||
Bcc: []string{"1362716835@qq.com"},
|
||||
ReplyTo: "huangxinyun@dreaminglife.cn",
|
||||
Subject: "test mail",
|
||||
Body: string(by),
|
||||
Subject: "测试邮件",
|
||||
Body: "这是测试邮件", //string(by),
|
||||
Attachment: []interfaces.MessageAttachment{
|
||||
// {
|
||||
// Name: "/code/statistic/out.xlsx",
|
||||
|
||||
Reference in New Issue
Block a user