Hi George, try with something like this :
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import sun.net.smtp.SmtpClient;
public class Mail extends HttpServlet
{
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
res.setContentType("text/html");
PrintWriter out = res.getWriter();
try {
SmtpClient smtp = new SmtpClient("smtp.mundivia.es");
smtp.from("[EMAIL PROTECTED]");
smtp.to("[EMAIL PROTECTED]");
PrintStream msg = smtp.startMessage();
msg.println("From: [EMAIL PROTECTED]");
msg.println("To: [EMAIL PROTECTED]");
msg.println("Subject: mail from a servlet");
msg.println();
msg.println("body of the mail");
msg.println();
smtp.closeServer();
out.println("Sent !!");
}
catch (IOException e) {
out.println(" Error handling the submission");
getServletContext().log(e, "Problem sending the e-mail");
}
}
}
Obviusly you should change the addresses !! and the server that you want to
use ! (here it is smtp.mundivia.es)
I think that it works !!
Xavier.
-----Mensaje original-----
De: George Ter-Saakov <[EMAIL PROTECTED]>
Para: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Fecha: lunes, 02 de agosto de 1999 22:12
Asunto: Email from servlet.
>Does anybody have something free which can help to send email.
>
>Thanks
>George.
>
>___________________________________________________________________________
>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
>
___________________________________________________________________________
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