JavaMail error in getting message variable
Hi SDN,
try{
PrintWriter out=response.getWriter();
InitialContext ctx=new InitialContext();
Session session = (Session) ctx.lookup("java:comp/env/mail/Email");
Properties props = session.getProperties();
out.println("Mail From >>" + props.getProperty("mail.from")); //senders email id
out.println("SMTP Server >>" + props.getProperty("mail.smtp.host")); // SMPT mail server name
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(props.getProperty("mail.from")));
message.setRecipients(Message.RecipientType.TO, new InternetAddress[]{new InternetAddress(request.getParameter("Receipient"))});
essage.setSubject(request.getParameter("Subject"));
message.setContent(request.getParameter("Msg"),"text/plain");
out.println("Message variable value" + message.getRecipients(Message.RecipientType.TO));
Transport.send(message);
out.println("
<b>Thank U. Your Message to "+request.getParameter("Recipient")+"was succesfully sent.<b>");
}
catch(Exception e)
{
e.printStackTrace();
}
We could not able to send a mail to the specified address using SMTP . Actual problem is the message variable in the above coding could not set the specified "from" address or "receipient" address . When we tried to display the set value it is returning the address as "Ljavax.mail.internet.InternetAddress;@57cd1b" . So suggest me how to overcome this.

