Announcement Announcement Module
Collapse
No announcement yet.
How to send mail to many addresses and keep sending if bad address? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to send mail to many addresses and keep sending if bad address?

    I guess the title says it all. I am using JavaMailSenderImpl to send an email to all registered users in the database. What I could do it create a new MimeMessage for each address and send it seperately. But this doesn't seem like to the way to go, seeing as it takes a while to establish the connection to the SMTP server, etc.

    So instead I create one MimeMessage and call the setTo(InternetAddress[]) method, passing it all of my addresses. The problem is, if any of the addresses is bad, the whole process fails and no mails are sent.

    Is there any way to tell Spring to ignore bad addresses, and to keep on sending? The array of InterAddress[] that I send in theory contains only valid addresses. but, for example, if I try to create a new InternetAddress with the string "xxx" it works, does not throw an exception. But of course, when I call send() it will fail.

    Any help much appreciated!

    Bob
Working...
X