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.

    评论

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line