Hello:

Please, would somebody know how to configure the Apache Web Server (in
Linux RedHat) for sending mail from a servlet that uses the JavaMail API ?

I have executed successfully a Java application which sends messages using
the JavaMail API. For that, I placed the JavaMail jar's (mail.jar,
pop3.jar, activation.jar) in the jre/lib/ext directory.

But, I didn't have success when I execute a servlet which sends messages
with JavaMail (additionally, I placed the JavaMail jar's in another
directory which is referenced in the wrapper.classpath of the
jserv.properties file).

The problem is about "Unknown SMTP host".

The exception message reported in the jserv.log is the following:
-----------------------------------------------------------------
javax.mail.SendFailedException: Sending failed;
   nested exception is:
         javax.mail.MessagingException: Unknown SMTP host: 200.13.195.2 ;
   nested exception is:
         java.net.UnknownHostException: 200.13.195.2
------------------------------------------------------------------
The exception message reported in the error_log is the following:
-----------------------------------------------------------------
java.net.UnknownHostException: 200.13.195.2
         at javax.mail.Transport.send0(Transport.java:218)
         at javax.mail.Transport.send(Transport.java:80)
         at TechSupport2.sendMail(TechSupport2.java:146)
         at TechSupport2.doPost(TechSupport2.java:35)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:521)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
         at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:
314)
         at org.apache.jserv.JServConnection.run(JServConnection.java:188)
         at java.lang.Thread.run(Thread.java:475)
--------------------------------------------------------------------

The SMTP host used by the servlet is a remote computer different from the
local Apache Web Server, but I have communication with this remote computer
(verified by the ping command). Besides that, the successfull application
Java uses the same remote machine.

The piece of code charged of sending the message in the servlet is the
following:
--------------------------------------------------------------
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
try{
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress("[EMAIL PROTECTED]"));
    InternetAddress[] address = {new InternetAddress("[EMAIL PROTECTED]")};
    msg.setRecipients(Message.RecipientType.TO, address);
    msg.setSubject("some subject");
    msg.setSentDate(new Date());
    msg.setText("this is the message");

    Transport transport = session.getTransport("smtp");
    transport.send(msg);       // the exception occurs here
}
catch (Exception e) {
    e.printStackTrace();
}

----------------------------------------------
Thanks you for any suggestions about this problem.

Maria Consuelo Franky

+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
Maria Consuelo FRANKY R.         [EMAIL PROTECTED]
CincoSOFT Ltda.                  http://cincosoft.tripod.com
Compa�ia de Ingenieros Constructores de Software
Carrera 15 # 80-48 (Ofc. 402)    Tel: (1)6230180, 6226350
Apartado Aereo 350.762           Fax: (1)2566774
Bogota * COLOMBIA                Celular: (033)3504483
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to