diff --git a/README.md b/README.md index 61e0797..1e0c070 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,9 @@ Go Simple Mail supports: https://pkg.go.dev/github.com/xhit/go-simple-mail/v2?tab=doc -Note: by default duplicated recipients throws an error, from `v2.13.0` you can use `email.AllowDuplicateAddress = true` to avoid the check. +Note 1: by default duplicated recipients throws an error, from `v2.13.0` you can use `email.AllowDuplicateAddress = true` to avoid the check. + +Note 2: by default Bcc header is not set in email. From `v2.14.0` you can use `email.AddBccToHeader = true` to add this. ## Download diff --git a/email.go b/email.go index 2aae703..0054819 100644 --- a/email.go +++ b/email.go @@ -32,6 +32,7 @@ type Email struct { SMTPServer *smtpClient DkimMsg string AllowDuplicateAddress bool + AddBccToHeader bool } /* @@ -349,6 +350,11 @@ func (email *Email) AddAddresses(header string, addresses ...string) *Email { return email } + // add Bcc only if AddBccToHeader is true + if header == "Bcc" && email.AddBccToHeader { + email.headers.Add(header, address.String()) + } + // add all addresses to the headers except for Bcc and Return-Path if header != "Bcc" && header != "Return-Path" { // add the address to the headers