Sending email: error when several users use same email(email received as how much user use this email)

Hey, I have a problem when trying to send emails to users.
first of all the email address isn’t an identity key. and I may have two or more users using the same email, so when I want to send an email for this email, it will be sent as many as I have users using this email.
EX:
user1’s email is example@gm.com
user2’s email is example@gm.com
user3’s email is example@gm.com

if I try to send an email with a specific template to “example@gm.com”, the email will be received three times.
Code for sending email:

    var templateName = "example";
    var emailEnvelope = new Backendless.Messaging.EmailEnvelope();
    emailEnvelope.setTo([user.email]);
    await Backendless.Messaging.sendEmailFromTemplate(templateName, emailEnvelope);

Hello @adel_kasno

When you use EmailTemplates there is a relationship between email and user object, that’s why you receive emails for each user.

Could you please tell us your use-case with details and we will try to help you.

Regards, Vlad

Hey @vladimir-upirov
In table user the email isn’t an identity, so it may contains user with same emails.
so let’s say we have 3 user with same email “example@gm.com
user1’s email is example@gm.com
user2’s email is example@gm.com
user3’s email is example@gm.com
and i want to send an email with template “example” for “example@gm.com

var templateName = "example";
var emailEnvelope = new Backendless.Messaging.EmailEnvelope();
emailEnvelope.setTo(["example@gm.com"]);
await Backendless.Messaging.sendEmailFromTemplate(templateName, emailEnvelope);

example@gm.com will receive 3 emails, completely the same emails but three times.
is it clear now ?

and in this kind of email, you do not need to have information about users, do you?

No, not really, I’m just sending a verification code.

As I said before the EmailTemplates is linked with users and if there are more than one user with the same email each of them will receive the email.

To send only one email I would recommend you to create a Custom API Service and use there Basic Emails API

1 Like

Okay thank you