Skip to content

Commit

Permalink
Allow Bcc in header (#81)
Browse files Browse the repository at this point in the history
Fix #38
  • Loading branch information
xhit committed Jul 4, 2023
1 parent 736a65b commit c86cc44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions email.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Email struct {
SMTPServer *smtpClient
DkimMsg string
AllowDuplicateAddress bool
AddBccToHeader bool
}

/*
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c86cc44

Please sign in to comment.