dongpang1898 2016-10-17 17:49
浏览 61

golang smtp使邮件成为希普里或重要

I tried to send a email using golang smtp https://github.com/golang/go/wiki/SendingMail and able to send email properly. Below is the code snippet

func sendEmail(server string) {
// Connect to the server, set the sender and recipient,
// and send the email all in one step.
headers := make(map[string]string)

headers["Subject"] = "Hi-Pri# Server " + server + " down"
headers["From"] = "YYYY@net"
headers["To"] = "XXXX@net"

body := "Hello, Test"

// Setup message
message := ""
for k, v := range headers {
    message += fmt.Sprintf("%s: %s
", k, v)
}
message += "
" + body
err := smtp.SendMail(
    "test.com:25",
    nil,
    "YYYY@net",
    []string{"XXXX@net"},
    []byte(message),
)
if err != nil {
    log.Fatal(err)
}

Im trying to send a hipri mail but couldn't fine the option to make a mail as hirpri or important one. Can someone help me

  • 写回答

1条回答 默认 最新

  • doufangxie0203 2019-02-21 18:41
    关注

    Add to your code:

    headers["X-Priority"] = "1 (Highest)"
    headers["X-MSMail-Priority"] = "High"
    headers["Importance"] = "High"
    

    That should work. However as said in comments, priority will be interpreted by your client, not your server. Will 100% depends on what your mail client decides to show.

    评论

报告相同问题?