i using java mail.
the following string format, , sends email.
string = "abc@test.com"; whereas following to2 string bad format, , expect throw error not.
string to2 = 'abctest' if (stringutils.hastext(to2)) { address[] toia2 = internetaddress.parse(to2); mailmessage.setrecipients(recipienttype.to, toia2); } it behaves: runs smoothly throw debugger, no error message in log, never sends email...
could teach me how should change code, can have error message thrown upon checking invalid "to", "cc" etc email address please?
thank you.
okay checked out code in mail-1.4. code in internetaddress.parse looks bad honest. way accept validations not all. looking @ class there method validate these validations.
so modifying code per below it.
public class sample { public static void main(string... args) throws addressexception { string to2 = "abctest"; if (stringutils.hastext(to2)) { internetaddress[] toia2 = internetaddress.parse(to2); for(internetaddress address:toia2){ address.validate(); } } } } i doing validation of email address above can add mailmessage.setrecipients(recipienttype.to, toia2); in loop or may deem appropriate.
Comments
Post a Comment