Skip to content

Commit c86cc44

Browse files
authored
Allow Bcc in header (#81)
Fix #38
1 parent 736a65b commit c86cc44

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ Go Simple Mail supports:
8282

8383
https://pkg.go.dev/github.com/xhit/go-simple-mail/v2?tab=doc
8484

85-
Note: by default duplicated recipients throws an error, from `v2.13.0` you can use `email.AllowDuplicateAddress = true` to avoid the check.
85+
Note 1: by default duplicated recipients throws an error, from `v2.13.0` you can use `email.AllowDuplicateAddress = true` to avoid the check.
86+
87+
Note 2: by default Bcc header is not set in email. From `v2.14.0` you can use `email.AddBccToHeader = true` to add this.
8688

8789
## Download
8890

email.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type Email struct {
3232
SMTPServer *smtpClient
3333
DkimMsg string
3434
AllowDuplicateAddress bool
35+
AddBccToHeader bool
3536
}
3637

3738
/*
@@ -349,6 +350,11 @@ func (email *Email) AddAddresses(header string, addresses ...string) *Email {
349350
return email
350351
}
351352

353+
// add Bcc only if AddBccToHeader is true
354+
if header == "Bcc" && email.AddBccToHeader {
355+
email.headers.Add(header, address.String())
356+
}
357+
352358
// add all addresses to the headers except for Bcc and Return-Path
353359
if header != "Bcc" && header != "Return-Path" {
354360
// add the address to the headers

0 commit comments

Comments
 (0)