Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BCC addresses are not added #295

Open
monopolly opened this issue Jul 20, 2023 · 5 comments
Open

BCC addresses are not added #295

monopolly opened this issue Jul 20, 2023 · 5 comments

Comments

@monopolly
Copy link

What I did:

create a email

What I expected:

email with bcc addresses

What I got:

email without bcc adresses

Release or branch I am using:

1.0.0

The problem

when you build the email in

func (p MailBuilder) Build() (*Part, error)

you don't add BCC field, only CC

if len(p.to) > 0 {
 h.Set("To", stringutil.JoinAddress(p.to))
}
if len(p.cc) > 0 {
 h.Set("Cc", stringutil.JoinAddress(p.cc))
}
if len(p.replyTo) > 0 {
 h.Set("Reply-To", stringutil.JoinAddress(p.replyTo))
}

//no bcc at all

so the email build like this:

Content-Transfer-Encoding: base64
Content-Type: text/plain; charset=utf-8
Date: Thu, 20 Jul 2023 12:01:54 +0300
From: <fff@aaaa.com>
Message-Id: <1689843714@478.aaaa.com>
Mime-Version: 1.0
Subject: =?utf-8?b?0KLQtdC80LA=?=
To: <a@gmail.com>
Cc: <a1@gmail.com>, <a2@gmail.com>

no BCC added

is it OK or you just forget to add BCC array to builder? Thanks

@dcormier
Copy link
Contributor

BCC in email is a trick. They don't go in the email itself, only in the SMTP conversation to the server. If it went in the email, a recipient could simply look at the email header to see who it was BCC'ed to.


Imagine an email being sent to fred@acme.example, jane@bigcorp.example, and BCC'ed to lucy@smithfield.example. The To header (which all recipients would receive) would look like this:

To: <fred@acme.example>, <jane@bigcorp.example>

There would be no BCC header at all.

The SMTP client would send three emails. One to the SMTP server for acme.example, one for bigcorp.example, and one to smithfield.example. For each of these, the SMTP client would only specify the recipient for that server, regardless of what the To or Cc headers say.

The receiving servers don't use those headers to determine who to deliver the email to. I can craft an email with headers along the lines of:

To: <you@corp.example>
Cc: <your-boss@corp.example>

But have only you receive it; not your boss.

TL; DR: Email headers are lies, and aren't used to determine what mailbox(es) an email is delivered to.

@jhillyerd
Copy link
Owner

Looks like the docs currently state the following for BCC methods:

This method only has an effect if the Send method is used to transmit the message, there is no effect on the parts returned by Build().

Should we expand on that?

@dcormier
Copy link
Contributor

It should probably be made more clear how BCC works, and that those recipients won't be in the email itself.

@monopolly
Copy link
Author

Thank you.

Offtopic: is there any "revolution" planned in email direction? Maybe it's time to switch to json in 2023, for example)?

@requaos
Copy link
Collaborator

requaos commented Jul 21, 2023

@monopolly every RFC is a "planned revolution". I have personally never submitted one myself, but I imagine that the process could start there. Good luck 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants