Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29769

Send individual emails to multiple recipients without using BCC with the SparkPost API

$
0
0

Our Django app uses SparkPost as an email provider. A new feature we are implementing should allow users to create their own organizational emails and send them to whoever they wish. Now, these emails should be received as individual ones, not with multiple recipients ("to") so that users can't see each other's address.

I have run a few tests with the SparkPost transmissions API. This is how you send an email:

sp = SparkPost(API_KEY)
response = sp.transmissions.send(recipients=emails, html=body, from_email=sender, subject=self.subject)

Where emails is a list of string literals.

In all test cases except one I did get individual emails with a single recipient just as I was after. But in one case the email had multiple "to" emails, and you could see each other's email address. I changed absolutely nothing in the code, this just happened.

Is there any way I could do that other than sending an individual transmission for each recipient? I'm worried about performance if it comes to that:

sp = SparkPost(API_KEY)
for email in emails:
    sp.transmissions.send(recipients=email, html=body, from_email=sender, subject=self.subject)

Viewing all articles
Browse latest Browse all 29769

Trending Articles