From d3689a7839c73aaa758bc2be52d607fad5764710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=9E=E6=A5=BD=E5=9D=82=20=E7=99=BD?= Date: Mon, 30 Oct 2023 15:43:25 +0000 Subject: [PATCH] fixbug --- mian.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mian.go b/mian.go index cfd9ae3..cb44f19 100644 --- a/mian.go +++ b/mian.go @@ -5,7 +5,6 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" "log" "mime" "net" @@ -13,6 +12,8 @@ import ( "os" "time" + "io" + "github.com/jhillyerd/enmime" "github.com/mhale/smtpd" ) @@ -67,7 +68,7 @@ func postMailContent(url string, key string, mailContent *MailContent) error { defer resp.Body.Close() // 读取响应体(如果需要) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(io.Reader(resp.Body)) if err != nil { return err } @@ -95,6 +96,9 @@ func mailHandler(origin net.Addr, from string, to []string, data []byte) error { // mediaType, params, err := mime.ParseMediaType(contentType) body := env.HTML + if len(body) == 0 { + body = env.Text + } fmt.Println("Body:", body) @@ -133,7 +137,7 @@ func main() { } defer file.Close() - configBytes, err := ioutil.ReadAll(file) + configBytes, err := io.ReadAll(io.Reader(file)) if err != nil { log.Fatalf("Error reading config file: %v", err) }