how to include CC and BCC in email using Go

huangapple go评论98阅读模式
英文:

how to include CC and BCC in email using Go

问题

如何在Go中的电子邮件功能中添加抄送(CC)和密送(BCC)?

以下是你的代码:

err := smtp.SendMail(
    "smtp.zoho.com",
    587,
    config.Email_id,
    config.Email_password,
    []string{email_to},
    []string{email_cc},
    []string{email_bcc},
    []byte(message),
)

SendMail函数中,你可以通过将抄送(CC)和密送(BCC)的电子邮件地址作为额外的参数传递给函数来添加抄送和密送功能。你可以将抄送地址放在[]string{email_cc}中,将密送地址放在[]string{email_bcc}中。

请确保在发送邮件之前,将email_ccemail_bcc替换为实际的抄送和密送电子邮件地址。

英文:

How to add CC and BCC on my email function in Go.

Here is my code

err := smtp.SendMail(
 "smtp.zoho.com",
 587,
 config.Email_id,
 config.Email_password,
 []string{email_to},

答案1

得分: 5

这取决于你使用的邮件库。简而言之,只需像处理其他标头(如“Subject:”或“To:”)一样,正常添加“Cc:”和“Bcc:”标头即可。

英文:

That depends on which mail library you're using. But the short version is: Just add the Cc: and Bcc: headers as usual, same as you do for any other header, such as Subject: or To:.

huangapple
  • 本文由 发表于 2017年7月9日 18:04:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/44995221.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定