Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

send a single email to a distribution list

 
JayaSiji Gopal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
using java program, is it possible to send only one email to a whole distribution list? Meaning...

the to field in the email has all the email addresses from the distribution list. This single email is sent out to everybody in the distribution list, rather than a single email/person in the list.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the JavaMail API -which is what you'd use to send emails from Java- you'll see that the Message class has addRecipient methods that let you add multiple email addresses at the same time, so what you're asking can be done.

However, putting all recipients in the To field is considered very bad practice - it exposes all addresses to everybody, which has consequences both concerning security and privacy. You really should not do that. It's much better to program a loop and send those emails individually.
[ January 22, 2008: Message edited by: Ulf Dittmer ]
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Putting all recipients into the BCC field would solve the privacy problems. But there are other advantages to sending one e-mail per recipient. For example, if there was a badly-formed address in your list, your server might not send messages to all of the other well-formed addresses. You would have to do some testing and fiddling about to make sure you knew how that would work and how it could be made reliable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic