Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Checking Invalid Addresses in JavaMail (urgent)

843830May 15 2002 — edited May 24 2002
Hello All,

I know that if any of the email addresses is invalid, SendFailedException is thrown by the JavaMail system. Where as this is not happening in my case. Even if I give addresses like abc@xyz.com, asdf@asdf.com, no exception is being generated. Do I need to set any property explicitly or any thing else. I am posting the code below.
Properties props = new Properties();
props.put("mail.smtp.host", "202.153.44.9");
props.put("mail.smtp.sendpartial", "true");
Session sess = Session.getDefaultInstance(props, null);
MimeMessage msg = new MimeMessage(sess);
msg.setFrom(new InternetAddress("myEmailId")); // in code I have given a correct email id here.
InternetAddress[] toAddresses = {new InternetAddress("abc@xyz.com")};
msg.setRecipients(Message.RecipientType.TO, toAddresses);
InternetAddress[] replyAddr = {new InternetAddress("issaque_md@hotmail.com")};
msg.setSubject("Bad address testing");
msg.setSentDate(new Date());

MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText("This is a test mail\nsent using Java Mail");

Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);

msg.setContent(mp);

Transport.send(msg);
Any help would be very kindful and will be greatly appreciated.

Thanks and best wishes
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 21 2002
Added on May 15 2002
3 comments
450 views