Return-Path: Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 72159 invoked from network); 26 Sep 2000 18:36:45 -0000 Received: from fw.infoplanning.net (HELO infoplanning.com) (@209.8.58.131) by locus.apache.org with SMTP; 26 Sep 2000 18:36:45 -0000 Received: (qmail 6187 invoked from network); 26 Sep 2000 17:46:52 -0000 Received: from minie (HELO johnnybravo) (192.168.0.189) by inet with SMTP; 26 Sep 2000 17:46:52 -0000 Message-ID: <014701c027e7$c7c1f640$bd00a8c0@infoplanning.com> From: "Berin Loritsch" To: References: Subject: Re: Sending Mail from XSP Date: Tue, 26 Sep 2000 14:30:00 -0400 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0144_01C027C6.40904B20" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_0144_01C027C6.40904B20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit ----- Original Message ----- From: "Torsten Curdt" To: Sent: Tuesday, September 26, 2000 1:55 PM Subject: RE: Sending Mail from XSP > > > > > > I know there is a mail.xsp tag sheet, but it looks like checking > > > > > > mail boxes. > > > > > > > > > > grab Sun's mail.jar + activation.jar it's quite easy... > > > > > > > > What properties and such have to be set? > > > > Can you send me some code to get me started? > > > > > > > > I keep getting exceptions. > > > Then catch 'em ;) > > > > > > ...sorry, I don't have anything here.... > > > > > > I remember you have to create Properties > > > and a Session and then you can create your > > > mail. > > > > > > Check the excellent documentation... > > > > The docs aren't that great, and I keep getting > > the exceptions that are generated by the XSP system > > which I can't catch. > > Sorry I don't have my sources here... but > there was a big pdf (60 pages or more) and > some examples. Maybe you missed them at sun? > > Why don't you try a simples test class first? Ok. Finally! mail.jar and activation.jar have to be in classpath-- either in Tomcat/lib or main classpath. I also had some typos... but they are fixed now. Enclosed is a copy of the file with names modified to protect the innocent. ------=_NextPart_000_0144_01C027C6.40904B20 Content-Type: application/octet-stream; name="white-paper.xsp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="white-paper.xsp" javax.mail.* javax.mail.internet.* static Properties props = new Properties(); static { props.put("mail.smtp.host", "mail"); // Only necessary if on another port... props.put("mail.smtp.port", "25"); } Session mailSession = null; Message message = null; String recipient = request.getParameter("recipient"); String subject = request.getParameter("subject"); String name = request.getParameter("name"); String company = request.getParameter("company"); String email = request.getParameter("email"); String paper = request.getParameter("paper"); String body = null; mailSession = Session.getDefaultInstance(props, null); mailSession.setDebug(true);
Your request has been received
try { message = new MimeMessage(mailSession); message.setFrom(new InternetAddress(email)); InternetAddress[] recipients = {new InternetAddress(recipient)}; message.setRecipients(Message.RecipientType.TO, recipients); message.setSubject(subject); body = name + " from " + company + "\n(email: " + email + ")\nRequested the following document:\n" + paper + "\n"; message.setContent(body, "text/plain"); Transport.send(message); } catch (Exception e) { e.toString(); }

Thank you for requesting the paper. It will automatically download in a few seconds.

If it fails to automatically download, click /papers/paper here .

------=_NextPart_000_0144_01C027C6.40904B20--