This commit is contained in:
神楽坂 白 2023-10-30 15:43:25 +00:00
parent 11f3f27d00
commit d3689a7839

10
mian.go
View File

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"log" "log"
"mime" "mime"
"net" "net"
@ -13,6 +12,8 @@ import (
"os" "os"
"time" "time"
"io"
"github.com/jhillyerd/enmime" "github.com/jhillyerd/enmime"
"github.com/mhale/smtpd" "github.com/mhale/smtpd"
) )
@ -67,7 +68,7 @@ func postMailContent(url string, key string, mailContent *MailContent) error {
defer resp.Body.Close() defer resp.Body.Close()
// 读取响应体(如果需要) // 读取响应体(如果需要)
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(io.Reader(resp.Body))
if err != nil { if err != nil {
return err return err
} }
@ -95,6 +96,9 @@ func mailHandler(origin net.Addr, from string, to []string, data []byte) error {
// mediaType, params, err := mime.ParseMediaType(contentType) // mediaType, params, err := mime.ParseMediaType(contentType)
body := env.HTML body := env.HTML
if len(body) == 0 {
body = env.Text
}
fmt.Println("Body:", body) fmt.Println("Body:", body)
@ -133,7 +137,7 @@ func main() {
} }
defer file.Close() defer file.Close()
configBytes, err := ioutil.ReadAll(file) configBytes, err := io.ReadAll(io.Reader(file))
if err != nil { if err != nil {
log.Fatalf("Error reading config file: %v", err) log.Fatalf("Error reading config file: %v", err)
} }