golang 郵件發送代碼片斷

//1 獲取當前發送郵件的時間ui

t := time.Now()orm

       s := t.Format("2006-01-02 15:04:05")域名

  

    //2準備發送人的郵箱信息(用戶名,密碼等,以及發送者郵箱域名)List

       hostname := "smtp.bszhihui.com"密碼

       auth := smtp.PlainAuth("", "yunwei@bszhihui.com", "xxxxxx", hostname)im

  

       //3 組織發送內容nw

       msg := []byte("From: DevOps<yunwei@bszhihui.com>\r\n" +時間

              "Subject: Notice " + sub + " - " + s + "\r\n" +auth

              "\r\n" +co

              mesg + "\r\n")

 

       //4 發送郵件 GMailList 是發送人的列表

       err := smtp.SendMail(hostname+":25", auth, "yunwei@bszhihui.com", GMailList, msg)

       if err != nil {

              return err

       }

相關文章
相關標籤/搜索