javax.mail.MessagingException: 501 Invalid Address
843830Sep 27 2001 — edited Sep 28 2001Okay, this one stumped me. Here's the situation: I have two PCs running win ME, connected via a router. I am able to access the internet as well as send/receive mail from both PCs. Both are running tomcat, and both have the same jsp code. However, I am only able to send smtp e-mail via jsp from one PC. The other gives me the following message:
javax.servlet.ServletException: Sending failed;
nested exception is:
javax.mail.MessagingException: 501 Invalid Address
Keep in mind that sending/receiving e-mail via outlook works fine on both pcs; it is only via the jsp page that i'm unable to send from one pc. This leads me to believe that it is somehow related to my pc or tomcat config. However, everything I check is consistent, including paths, etc.
My code is as follows:
Properties props = System.getProperties();
props.put("mail.smtp.host", mailhost);
props.put("mail.smtp.from", senderAddress);
Session emailsession = Session.getDefaultInstance(props, null);
try {
Message email = new MimeMessage(emailsession);
email.setFrom(new InternetAddress(senderAddress));
InternetAddress[] address = {
new InternetAddress(formRecipient) };
email.setRecipients(Message.RecipientType.TO,address);
email.setSubject(req.getServletPath());
email.setSentDate(new Date());
email.setHeader("X-Mailer","MailFormJava");
email.setText(message.toString());
Transport.send(email);
} catch (MessagingException e) {
throw new JspException (e.getMessage());
}
return (message.toString());
}
I'm hoping that ~someone~ out there will be able to end my misery.
Thanks in advance for your help!