码迷,mamicode.com
首页 > 其他好文 > 详细

golang 发送多人邮件 textproto.Error{Code:554, Msg:"Transaction failed: Illegal semicolon, not in group"

时间:2015-01-22 17:54:57      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:

网上很多版本发送邮件都是用; 号,关键在于,多个邮件分割不能用; 号,需要用,号

 

// send mail
func SendMail(subject string, message string, from *mail.Address, to []string, smtpConfig SmtpConfig, isHtml bool) error {
    auth := smtp.PlainAuth(
        "",
        smtpConfig.Username,
        smtpConfig.Password,
        smtpConfig.Host,
    )
    contentType := "text/plain"
    if isHtml {
        contentType = "text/html"
    }
    msg := fmt.Sprintf("To: %s\r\nFrom: %s\r\nSubject: %s\r\nContent-Type: %s; charset=UTF-8\r\n\r\n%s",
        strings.Join(to, ","), from.String(), subject, contentType, message)
    return smtp.SendMail(smtpConfig.Addr, auth, from.Address, to, []byte(msg))
}

 

golang 发送多人邮件 textproto.Error{Code:554, Msg:"Transaction failed: Illegal semicolon, not in group"

标签:

原文地址:http://www.cnblogs.com/zhangqingping/p/4242061.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!