|
Hello All,
I am using JavaMail API to send emails,but the problem is that if an Invalid Address(e.g [EMAIL PROTECTED]) comes into picture it throws me an "javax.mail.SendFailedException",and when i try to Retreive the InvalidAddress using, "Address[] invalid = sfe.getInvalidAddresses();" and print a SOP after this ,the value of "invalid" comes out to be "Null"... The complete Exception is, javax.mail.SendFailedException: Sending Failed: 504: ?.. <recipient address rejected: need fully qualified address> The code which is being used is as follows, <Code>.... try { Transport.send(msg); System.out.println ("The Email has been sent successfully...."); }catch (javax.mail.SendFailedException sfe) { ArrayList al = new ArrayList(); Collection badAddresses = null; Address[] invalid = sfe.getInvalidAddresses(); System.out.println("Collected InvalidAddress...."+invalid );//The value of this SOP is Null......and loop below does not get executed.... if (invalid != null) { if (invalid.length > 0) { for (int x = 0; x < invalid.length; x++) { String invalidAddresses = invalid[x].toString(); InvalidAddresses invalidAdd = null; invalidAdd = new InvalidAddresses(invalidAddresses); al.add(invalidAdd); }badAddresses=al; } actModel = new ActivityModel(badAddresses); } }catch (Exception e) { }return actModel; Can anybody shed some light on this,any suggestions are greatly appreciated. Thanks Regards Sameer |
