fix
This commit is contained in:
parent
ee7d82e174
commit
0a748dfab7
|
@ -5,10 +5,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"fusenapi/utils/check"
|
"fusenapi/utils/check"
|
||||||
"fusenapi/utils/fstpl"
|
"fusenapi/utils/fstpl"
|
||||||
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
"sync"
|
"sync"
|
||||||
"text/template"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/smtp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/474420502/requests"
|
"github.com/474420502/requests"
|
||||||
|
@ -16,6 +17,113 @@ import (
|
||||||
"github.com/zeromicro/go-zero/core/logx"
|
"github.com/zeromicro/go-zero/core/logx"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestEmailSend(t *testing.T) {
|
||||||
|
|
||||||
|
// 设置发件人和收件人信息
|
||||||
|
from := "support@fusenpack.com"
|
||||||
|
to := []string{"474420502@qq.com"}
|
||||||
|
|
||||||
|
// 设置smtp服务器地址,端口和认证信息
|
||||||
|
smtpServer := "smtp.gmail.com"
|
||||||
|
|
||||||
|
auth := smtp.PlainAuth("", "support@fusenpack.com", "wfbjpdgvaozjvwah", smtpServer)
|
||||||
|
|
||||||
|
body := `<div>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<sign signid="1" nreadytime="1693908994426">
|
||||||
|
<hr align="left" style="margin: 0 0 10px 0;border: 0;border-bottom:1px solid #E4E5E6;height:0;line-height:0;font-size:0;padding: 20px 0 0 0;width: 50px;">
|
||||||
|
<div style="font-size:14px;font-family:Verdana;color:#000;">
|
||||||
|
<a class="xm_write_card" id="in_alias" style="white-space: normal; display: inline-block; text-decoration: none !important;font-family: -apple-system,BlinkMacSystemFont,PingFang SC,Microsoft YaHei;" href="https://wx.mail.qq.com/home/index?t=readmail_businesscard_midpage&nocheck=true&name=3e&icon=http%3A%2F%2Fthirdqq.qlogo.cn%2Fg%3Fb%3Doidb%26k%3DeXzYkarOrzZhXZpDqM83lA%26kti%3DZOJARgAAAAI%26s%3D140%26t%3D1556039949&mail=474420502%40qq.com&code=WmPZN_MDFxAnvpYZtHjQqsJv-zHkDdwEwftrVq-KClPFKtdQ71RDiVxIOZ7rrthFIT9ubnRFwkPjfKb3swLDIQ" target="_blank">
|
||||||
|
<table style="white-space: normal;table-layout: fixed; padding-right: 20px;" contenteditable="false" cellpadding="0" cellspacing="0">
|
||||||
|
<tbody>
|
||||||
|
<tr valign="top">
|
||||||
|
<td style="width: 40px;min-width: 40px; padding-top:10px">
|
||||||
|
<div style="width: 38px; height: 38px; border: 1px #FFF solid; border-radius:50%; margin: 0;vertical-align: top;box-shadow: 0 0 10px 0 rgba(127,152,178,0.14);">
|
||||||
|
<img src="http://thirdqq.qlogo.cn/g?b=oidb&k=eXzYkarOrzZhXZpDqM83lA&kti=ZOJARgAAAAI&s=140&t=1556039949" style="width:100%;height:100%;border-radius:50%;pointer-events: none;">
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td style="padding: 10px 0 8px 10px;">
|
||||||
|
<div class="businessCard_name" style="font-size: 14px;color: #33312E;line-height: 20px; padding-bottom: 2px; margin:0;font-weight: 500;">
|
||||||
|
3e
|
||||||
|
</div>
|
||||||
|
<div class="businessCard_mail" style="font-size: 12px;color: #999896;line-height: 18px; margin:0;">
|
||||||
|
474420502@qq.com
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</sign>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div style="position: relative;">
|
||||||
|
<includetail>
|
||||||
|
<div>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
<div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">
|
||||||
|
------------------ 原始邮件 ------------------
|
||||||
|
</div>
|
||||||
|
<div style="font-size: 12px;background:#efefef;padding:8px;">
|
||||||
|
<div>
|
||||||
|
<b>
|
||||||
|
发件人:
|
||||||
|
</b>
|
||||||
|
"support" <support@fusenpack.com>;
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<b>
|
||||||
|
发送时间:
|
||||||
|
</b>
|
||||||
|
2023年9月5日(星期二) 晚上6:16
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<b>
|
||||||
|
收件人:
|
||||||
|
</b>
|
||||||
|
"3e"<474420502@qq.com>;
|
||||||
|
<wbr>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<b>
|
||||||
|
主题:
|
||||||
|
</b>
|
||||||
|
Simple Mail
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</includetail>
|
||||||
|
</div>`
|
||||||
|
// 构建邮件内容
|
||||||
|
message := []byte("To: " + to[0] + "\r\n" +
|
||||||
|
"Subject: Simple Mail\r\n" +
|
||||||
|
"\r\n" +
|
||||||
|
body)
|
||||||
|
|
||||||
|
// 发送邮件
|
||||||
|
err := smtp.SendMail(smtpServer+":587", auth, from, to, message)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPost(t *testing.T) {
|
func TestPost(t *testing.T) {
|
||||||
r := mux.NewRouter()
|
r := mux.NewRouter()
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package fstpl
|
package fstpl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"html/template"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func AutoParseTplFiles() *template.Template {
|
func AutoParseTplFiles() *template.Template {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user