- This topic has 1 reply, 2 voices, and was last updated 18 years, 9 months ago by
Riyad Kalla.
-
AuthorPosts
-
saravanan_vMemberHI
Im trying to write a code that sends mail to specific mail ids..
following is the piece of code im using..
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out=response.getWriter();
response.setContentType(“text/html”);
try
{
Properties props=new Properties();
props.put(“mail.smtp.host”,”<using the IP adress of the SMTP server here>”);
Session session1 = Session.getDefaultInstance(props,null);
String s1 = request.getParameter(“text1”);
String s2 = request.getParameter(“text2”);
String s3 = request.getParameter(“text3”);
String s4 = request.getParameter(“area1”);
Message message =new MimeMessage(session1);
message.setFrom(new InternetAddress(s1));
message.setRecipients
(Message.RecipientType.TO,InternetAddress.parse(s2,false));
message.setSubject(s3);
message.setText(s4);
Transport.send(message);
out.println(“mail has been sent”);
}
catch(Exception ex)
{
System.out.println(“ERROR…..”+ex);
}
}when i run this program im getting this error..
ERROR…..javax.mail.SendFailedException: Sending failed;
nested exception is:
class javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection resetproblem is that im developing an application one of the functions of which is to send mail to specific email ids..
so i asked for the smtp server ip from the admin..
they send me a message saying the the smtp relay access has been provided to <IP 1> to the smtp server <IP 2>
neither of these is the IP adress of my system..
which among these two IPs should i use.. currently Im using the IP 2 which is the IP adress of the actual server itself..
should I ask my admin to provide the same access to my system also ?
or is there something wrong Im doing ?
Thanks
October 17, 2006 at 12:45 pm #260584
Riyad KallaMemberIt’s hard to say, you likely just want to duplicate whatever settings you have in aworking Email client. Try and setup your email client to use the relay to make sure it works first, then duplicate those settings in your code.
-
AuthorPosts