Imran
Imran

Reputation: 1902

Spring email template, hide receivers

I need to send email notification to web site subscribers. All subscribers receive simply the same thing. I can create a for loop and send one email per user, which is not very efficient as the same thing is being copied from the app to email server every time. On the other hand, I can set multiple receivers in in the "to" field. This is not good as I don't want to expose the emails to all receivers. So, is there an option to send a single email to all users and hide the receivers from each other?

Upvotes: 1

Views: 552

Answers (1)

Mike Nakis
Mike Nakis

Reputation: 62045

Sending each email individually may be inefficient, but it is not like you have to carry each email by hand to the mail server, so it should not be a problem. If you already have it working, I would suggest that you leave it as it is. Especially since this method has an advantage which I will show further down.

If you really feel like spending time to optimize things, you can place recipients of the message in the Bcc: field. This means that they will not see each others' address. (The mail server will make sure they don't.)

There are two problems with Bcc:

  • Most mail servers impose a limit on how many people you may Bcc:, and it is not like they advertise what this limit is, so you might end up having to discover it yourself with trial and error, possibly accidentally spamming some people in the process.

  • Most mail servers will still require you to put some recipient in the To: field, regardless of who you put in Bcc:, and then the problem is that people are going to be receiving emails addressed to some unknown-to-them address, like the "undisclosed-recipients" receiver of mailing lists of old. And anti-spam filters tend to dislike this kind of recipient.

Sending each email individually allows you to address each email to its proper intended recipient. Email nowadays is plagued by spam and spam filters, so it is best to not take chances with it.

Upvotes: 2

Related Questions