JavaMe開辟繪制可主動換行文本。本站提示廣大學習愛好者:(JavaMe開辟繪制可主動換行文本)文章只能為提供參考,不一定能成為您想要的結果。以下是JavaMe開辟繪制可主動換行文本正文
本文實例講述了golang完成經由過程smtp發送電子郵件的辦法。分享給年夜家供年夜家參考,詳細以下:
明天寫了一個公司的郵件發送後台辦事,php只須要把郵件存入數據庫,然後golang寫的mailservice就會吧郵件發送出去.這個公司的代碼就不收回來的,認為帶有公司的營業邏輯,我把代碼整頓了一下宣布出來供年夜家參考.呵呵
package main
import (
"fmt"
"net/mail"
"net/smtp"
"encoding/base64"
)
func main() {
b64 := base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
host := "smtp.mail.com"
email := "[email protected]"
password := "password"
toEmail := "[email protected]"
from := mail.Address{"發送人", email}
to := mail.Address{"吸收人", toEmail}
header := make(map[string]string)
header["From"] = from.String()
header["To"] = to.String()
header["Subject"] = fmt.Sprintf("=?UTF-8?B?%s?=", b64.EncodeToString([]byte("郵件題目2")))
header["MIME-Version"] = "1.0"
header["Content-Type"] = "text/html; charset=UTF-8"
header["Content-Transfer-Encoding"] = "base64"
body := "我是一封電子郵件!golang收回.";
message := ""
for k, v := range header {
message += fmt.Sprintf("%s: %s\r\n", k, v)
}
message += "\r\n" + b64.EncodeToString([]byte(body))
auth := smtp.PlainAuth(
"",
email,
password,
host,
)
err := smtp.SendMail(
host+":25",
auth,
email,
[]string{to.Address},
[]byte(message),
)
if err != nil {
panic(err)
}
}
願望本文所述對年夜家Go說話法式設計有所贊助。
lt;img src='<%#Page.ResolveUrl(folder + Eval("Name"))%>' width="200" height="200" />