Thanks for reply
but I didnt' get what is problem actualt ,beca on another machine in my domain this application is working fine means sending mails but problem with my machine
please let me know what will be the reasons behind this
I am Using JavaMail1.2 & jaf-1.0.1
I am sending my code to U
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.mail.*;
import javax.mail.event.*;
import javax.mail.internet.*;
import javax.activation.*;
//import javax.mail.smtp;
public class MailClient extends HttpServlet
{
final
String mailHost="202.9.128.101";
//final String mailHost="mail.ip.eth.net";
String source,dest,sub,content,fileName,fileStr="",str;
File file;
FileDataSource fileSource;
PrintWriter out;
public void init(ServletConfig config)throws ServletException
{
super.init(config);
}
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException{
try {
res.setContentType("text/html");
out = res.getWriter();
dest=req.getParameter("to");
source=req.getParameter("from");
sub=req.getParameter("sub");
content=req.getParameter("content");
fileName=req.getParameter("fileNm");
file = new File(fileName);
Properties prop = System.getProperties();
prop.put("mail.smtp.host",mailHost);
Session session = Session.getDefaultInstance(prop, null);
//Session session = Session.getInstance(prop, null);
InternetAddress[] address= InternetAddress.parse(dest);
MimeMessage msg = new MimeMessage(session);
msg.addHeader("X-Priority", "1");
msg.setRecipients(Message.RecipientType.TO,address);
msg.setFrom(new InternetAddress(source));
msg.setSubject(sub);
if(file.exists())
{
MimeBodyPart body = new MimeBodyPart();
body.setText(content);
MimeBodyPart attachment = new MimeBodyPart();
fileSource = new FileDataSource(file);
attachment.setDataHandler(new DataHandler(fileSource));
attachment.setFileName(fileSource.getName());
Multipart part = new MimeMultipart();
part.addBodyPart(body);
part.addBodyPart(attachment);
msg.setContent(part);
}
else
{
msg.setText(content);
}
Transport.send(msg);
out.println("Mail send successfully");
}
catch(Exception e)
{
out.println(e.toString());
}
}
}
Exception is
453dce javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: 202.9.128.101, port: 25; nested exception is: java.net.NoRouteToHostException: Host unreachable: no further information
Please Help me out
Please correct me If I am wrong
Tahnks