|
@@ -48,6 +48,27 @@ func GSendMail(from, to, cc, bcc, subject, body, fname, rename string, auth *Gma
|
|
|
return gSend(auth, m, to)
|
|
|
}
|
|
|
|
|
|
+func GSendMail_B(from, to, cc, bcc, subject, body, fname string, fb []byte, auth *GmailAuth) bool {
|
|
|
+ m := gomail.NewMessage()
|
|
|
+ m.SetAddressHeader("From", auth.User, from) // 发件人
|
|
|
+ m.SetHeader("To",
|
|
|
+ m.FormatAddress(to, "收件人")) // 收件人
|
|
|
+ if cc != "" {
|
|
|
+ m.SetHeader("Cc", m.FormatAddress(cc, "收件人")) //抄送
|
|
|
+ }
|
|
|
+ if bcc != "" {
|
|
|
+ m.SetHeader("Bcc", m.FormatAddress(bcc, "收件人")) // 暗送
|
|
|
+ }
|
|
|
+ m.SetHeader("Subject", subject) // 主题
|
|
|
+ m.SetBody("text/html", body) // 正文
|
|
|
+ if fname != "" {
|
|
|
+ h := map[string][]string{"Content-Type": {"text/plain; charset=UTF-8"}}
|
|
|
+ m.Attach_new(fb, gomail.Rename(fname), gomail.SetHeader(h)) //添加附件
|
|
|
+ //m.Attach(fname) //添加附件
|
|
|
+ }
|
|
|
+ return gSend(auth, m, to)
|
|
|
+}
|
|
|
+
|
|
|
//
|
|
|
func gSend(auth *GmailAuth, m *gomail.Message, to string) bool {
|
|
|
mailLock.Lock()
|