Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sending mail to multiple receipients

 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

My requirement is as follows:

I've a To address and multiple CC addressess and BCC addressess. Now, when I try to send mail, the mail should be sent to all valid addressess and the invalid ones should be caught in the exception.

Please help me to do this using JavaMail API.

Thanks in Advance..
 
Paul Clapham
Sheriff
Posts: 21128
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's your problem? Is it that obvious garbage addresses are causing an exception, and none of the addressees are getting the message? Or is it that you want the server to instantly check whether all the addresses correspond to valid accounts on servers that actually exist, and tell you right away? Or is it something else? The term "valid" for an e-mail address is rather vague.
 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is, the junk addresses cause the exception and because of this, none of the mentioned addresses receive the message. I want to avoid this and send mail to all addresses except the junk ones.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's rather unusual that an email wouldn't be sent to a valid address just because the one of the other addresses was invalid.
What kind of validation do you perform before sending? Regular expressions are a common way. This one weeds out a lot of junk: [\\p{L}0-9_-]+(\\.[\\p{L}0-9_-]+)*@([\\p{L}0-9_-]+\\.)+[a-zA-Z]{2,7}
 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I'm right, regular expressions are used to validate the format of the addresses. For example, the email id is a.b@c.com. While entering the id in CC field, it is entered as ab@c.com and z.y@c.com(which is a valid one) in the TO field. Now, when i hit send, mail should be sent to z.y@c.com which is a valid id and exception should be thrown for ab@c.com. But, what i get is only the exception for the invalid id and not the mail for the valid id.

Hope I'm clear of the problem i'm facing...
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems more of a configuration issue of the email server. Like I said, email servers normally retry sending emails which pose problems, but deliver to the other addresses in the list just fine. Maybe you can run a few tests against your server with a regular email client, to see how it behaves in this regard.
 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is possible in SMTPMessage. It has a method setSendPartial() which takes a boolean and if this is set to true, mail will be sent to valid addresses and exception is thrown for invalid ones.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic