java.sun.com/products/
look for the java mail api.
anderson wrote:
> Where I found the packages : javax.mail.* , javax.activation.* ?
>
> Thanks
> anderson
>
> Geert Van Damme wrote:
>
> > Joseph, thanks for the other mail links.
> >
> > However, the servlet was easier that I expected.
> > Here's the code I use
> >
> > import java.io.*;
> > import java.util.*;
> > import java.net.*;
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> > import javax.mail.*;
> > import javax.mail.internet.*;
> >
> > public class MailPage extends HttpServlet{
> >
> > private String SMTPHost = "";
> >
> > public void init(ServletConfig config) throws ServletException{
> > super.init(config);
> > SMTPHost = getInitParameter("host");
> > }
> >
> > public void service(HttpServletRequest req, HttpServletResponse res)
> > throws ServletException, IOException {
> > String source = req.getParameter("source");
> > String from = req.getParameter("from");
> > String to = req.getParameter("to");
> > String subject = req.getParameter("subject");
> > PrintWriter out = res.getWriter();
> > res.setContentType("text/plain");
> >
> > try{
> > Properties sysProps = System.getProperties();
> > sysProps.put("mail.smtp.host",SMTPHost);
> > Session session = Session.getInstance(sysProps,null);
> >
> > MimeMessage message = new MimeMessage(session);
> >
> > Address fromAddress = new InternetAddress(from);
> > message.setFrom(fromAddress);
> >
> > Address[] toAddress = InternetAddress.parse(to);
> > message.setRecipients(Message.RecipientType.TO,toAddress);
> >
> > message.setSubject(subject);
> >
> > StringBuffer text = new StringBuffer();
> > URL url = new URL( source );
> > BufferedReader in = new BufferedReader( new
> > nputStreamReader( url.openStream() ) );
> > String line = null;
> > // use a String as buffer
> > while ((line=in.readLine()) != null){
> > text.append(line);
> > }
> > message.setText(text.toString());
> > Transport.send(message);
> >
> > }
> > catch (IOException e){
> > out.println("Error : "+e.getClass()+" "+e.getMessage());
> > }
> > catch (AddressException e){
> > out.println("Error in address : "+e.getClass()+"
>"+e.getMessage());
> > }
> > catch (SendFailedException e){
> > out.println("Error in send : "+e.getClass()+"
>"+e.getMessage());
> > }
> > catch (MessagingException e){
> > out.println("Error in message : "+e.getClass()+"
>"+e.getMessage());
> > }
> >
> > }
> > }
> >
> > You need to specify the SMTPHost as an init parameter.
> > URL parameters are to, from, subject and source
> > Source is the full path to a webpage like http://www.gojasper.be
> >
> > I'll try to install this on my server and let you know where this can be
> > tested.
> >
> > Geert 'Darling' Van Damme
> >
> > > -----Original Message-----
> > > From: A mailing list about Java Server Pages specification and reference
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of Geert Van Damme
> > > Sent: woensdag 3 mei 2000 12:41
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Emailling within JSP
> > >
> > >
> > > However, even when using javamail, emailing from JSP isn't obvious.
> > > Of course you can do it, but in that case, your whole code is in
> > > between <%
> > > %> with lot's of println("blablabla ") statements and you're not really
> > > doing JSP. That's a plain servlet ;-)
> > >
> > > It would be very nice if you could use a JSP approach to sending email.
> > >
> > > Here's what I'd like to do:
> > > Make a servlet that takes address and subject as a parameter and
> > > also a URL
> > > to a JSP page.
> > > the servlet makes a URLConnection to that JSP and routes the result to an
> > > email.
> > > that way you can use create your emails like you create JSP. Isn't that
> > > wonderful?
> > > But before I do this: has anyone else made this servlet? ;-)
> > >
> > > I'll keep you informed when it's ready.
> > >
> > > Geert 'Darling' Van Damme
> > >
> > >
> > > -----Original Message-----
> > > From: A mailing list about Java Server Pages specification and reference
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of Germ�n L�pez Castro
> > > Sent: woensdag 3 mei 2000 12:26
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Emailling within JSP
> > >
> > >
> > > Hi, you all.
> > >
> > > I've heard you talking 'bout Javamail... What's it? How can I use it?
> > >
> > > Thanxalot.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Consigue tu direcci�n de email gratis y permanente en
> > http://WWW.LETTERA.NET
> > ========================= To unsubscribe: mailto [EMAIL PROTECTED] with
> > body: "signoff JSP-INTEREST". Some relevant FAQs on JSP/Servlets can be
> > found at: http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=P
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=rvlets
> >
> > ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> > JSP-INTEREST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
> >
> > ===========================================================================
> > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> > Some relevant FAQs on JSP/Servlets can be found at:
> >
> > http://java.sun.com/products/jsp/faq.html
> > http://www.esperanto.org.nz/jsp/jspfaq.html
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets