convert from format

这个提交包含在:
betterfor
2022-10-10 09:47:39 +08:00
父节点 28c001267b
当前提交 fa5025c4d4

11
main.go
查看文件

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"regexp"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -35,7 +36,7 @@ func main() {
m := gomail.NewMessage() m := gomail.NewMessage()
m.SetHeader("Subject", subject) m.SetHeader("Subject", subject)
m.SetHeader("From", from) m.SetHeader("From", getFrom(from, username))
m.SetHeader("To", to...) m.SetHeader("To", to...)
m.SetHeader("Cc", cc...) m.SetHeader("Cc", cc...)
m.SetHeader("Bcc", bcc...) m.SetHeader("Bcc", bcc...)
@ -97,3 +98,11 @@ func convertInt(i string) int {
ints, _ := strconv.Atoi(i) ints, _ := strconv.Atoi(i)
return ints return ints
} }
func getFrom(from, username string) string {
ok, _ := regexp.MatchString(`.+ <.+@.+>`, from)
if ok {
return from
}
return fmt.Sprintf("%s <%s>", from, username)
}