now THIS is the kind of response I would *expect* from a list.. although it *technically* is a Jakarta list not a *Learn how to make Java Servlets* List. Just a reminder to staying on topic. Say, is there a mailing list out there to direct code-specific issues to? Maybe that would help.. perhaps the folk at apache could start one? Say... [EMAIL PROTECTED]? -----Original Message----- From: Hemant Singh [mailto:[EMAIL PROTECTED]] Sent: Tuesday, June 05, 2001 6:47 AM To: [EMAIL PROTECTED] Subject: Re: Java servlet that sends form data to email HI Use following code import javax.servlet.*; import javax.servlet.http.*; import sun.net.smtp.*; import java.io.*; public class SendMail extends HttpServlet{ String to ="[EMAIL PROTECTED]"; SmtpClient mailClient; public void init(ServletConfig config){ try{ mailClient = new SmtpClient("12.10.194.226"); super.init(config); }catch(Exception e){ System.out.println(e); } } public void doGet(HttpServletRequest req,HttpServletResponse res){ try{ res.setContentType("text/html"); String name = req.getParameter("name"); String from = req.getParameter("email"); String subject = req.getParameter("subject"); if(subject ==null || subject.length()<1){ subject ="(none)"; } String msg = req.getParameter("msg"); send(name,from,to,msg,subject); res.sendRedirect("http://12.10.194.239/mru/Thanks.html"); }catch(Exception e){ System.out.println(e); } } private void send(String name,String from,String to,String msg,String subject){ try{ mailClient.from(from); mailClient.to(to); PrintStream ps = ps = mailClient.startMessage(); ps.println("From: "+ from ); ps.println("To: "+ to ); ps.println("Subject: "+subject ); ps.print("\r\n"); ps.println(); ps.println(msg); ps.println(); ps.flush(); ps.close(); //mailClient.closeServer(); }catch(Exception e){ System.out.println(e); } } } --- Peter Choe <[EMAIL PROTECTED]> wrote: > use the javamail api. > > "Alkmini D." wrote: > > > > HI all! > > > > Sorry for the newbie question. Can anyone give me > any > > hints on how to make a java servlet that reads > form > > data and sends it to an email address? > > > > Thanks ! > > > > > ____________________________________________________________ > > Do You Yahoo!? > > Get your free @yahoo.co.uk address at > http://mail.yahoo.co.uk > > or your free @yahoo.ie address at http://mail.yahoo.ie __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail - only $35 a year! http://personal.mail.yahoo.com/
RE: Java servlet that sends form data to email
Swart, James (Jim) ** CTR ** Tue, 05 Jun 2001 10:27:17 -0700
- Java servlet that sends form data to email Alkmini D.
- Re: Java servlet that sends form data to... Peter Choe
- Re: Java servlet that sends form dat... Hemant Singh
- Re: Java servlet that sends form data to... Pae Choi
- Re: Java servlet that sends form dat... Johnathan Smith
- RE: Java servlet that sends form data to... Swart, James (Jim) ** CTR **
- To unsubscribe (WAS Re: Java servlet... Chu J Tan
- Swart, James (Jim) ** CTR **
