Search code examples
springjakarta-mail

Java Mail: how to show a group name as the recipient in an email instead of showing all recipient email addresses


In my web application, I need to send an email to a group of people.

If I make the email addresses of the group of people as the TO addresses, then each recipient will be able to see who other recipients are and their email addresses. This is not what I want.

I want to make the email addresses of the group of people as the BCC addresses, which I am able to. However, I want to show "Our Team" as the recipient in the email to everybody. How can I do this? I googled but did not find useful information.

Any info or pointer is really appreciated.

Thanks in advance!


Solution

  • You can put whatever you want in the To header, including a fake email address, and then use the send method to send the message to whatever recipients you want.

    But, you should ask yourself what you expect to happen if someone does a reply-all to the message. Do you want the reply to go to all members of your team? If so, you really need to create a mailing list, which will simplify the process of sending the message as well. Most mail server support some sort of mailing list capability. If you're using your own mail server (e.g., your company mail server), you may also want some mailing list management software.