• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sending mail to multiple receipients

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
This tiny ad is wafer thin:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic