简体   繁体   中英

How do i send a mass email individually using Spring java?

I want to send an email to a group of several contacts. I don't want to put all the email addresses in the setTo(String[] contacts) field, because I don't want that they can see each other. I don't want to put all the email addresses in the setBcc(String[] contacts) field neither, because then they can't even see their own email.

I want to send the email out so that each contact sees only their own email address in the "TO" field. How can I do that? Is there a well-known method or approach? Or should I send an email to each contact using a loop? For example, something like this:
for (String oneContact : stringArrayOfRecipients){ sendEmail(oneContact, message); }

I am pretty sure that you will have to use a loop to do that.

SMTP protocol, which is used by the mail servers to deliver mail, has no mechanism to do what you want to do. In addition, the To property in the email is part of the message body, which can be set to any arbitrary string.

The problem with looping through a mailing list like you describe, is that your emails will look like spam. (A lot of identical messages, send to a lot of users) They may get flagged because of that.

Alternatively, you may be able to set the To field to a generic address such as "Mailing List", and use Bcc for the recipients.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM