用过的baidu空间,太难用了,还是cnblogs好用
GZ.Jackey
学无止境,博采众长。

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

 

// 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))
}

 

posted on 2015-01-22 16:26  GZ.Jackey  阅读(5229)  评论(0编辑  收藏  举报