[opencms-dev] sending email?

Alexander Wallace aw at avatartechnology.com
Mon Aug 22 15:48:37 CEST 2005


Ola... this should help you:

<%@ page import="org.opencms.mail.CmsSimpleMail" %>
<%

CmsSimpleMail sm = new CmsSimpleMail();

sm.setMsg("You like it?");
sm.addTo("someone at somplace.com");
sm.setFrom("other at here.com");
sm.send();

%>

On Friday 19 August 2005 04:04 pm, Aleksandra wrote:
> Ola,
> I want to use jsp that will take information from html page
> with forms for sending emails,how can i implement
> these,explain me the jsp file,should it be static
> exported?No,right?
> I want to use jstl,because my server allows that.
> Does anyone maybe have solve this?
> My jsp till now look like this:
> 
> >>
> <jsp:directive.page import="javax.mail.*"/> 
> <jsp:directive.page import="javax.mail.internet.*"/> 
> <jsp:directive.page import="java.util.*"/>
> 
> <!doctype html public "-//w3c//dtd html 4.0
> transitional//en">
> <html>
> <%@ taglib uri="WEB-INF/c-1.0.6.tld" prefix="c" %>
> <%@ taglib uri="WEB-INF/sql-1.0.6.tld" prefix="sql" %>
> 
> <%@ page pageEncoding="UTF-8" %><%@ page session="false" %>
> <%@ taglib prefix="cms"
> uri="http://www.opencms.org/taglib/cms" %>
> 
> <head>
> <title>Eteg - Tecnologia adaptada à sua
> empresa</title>
> <meta HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html;
> CHARSET=<cms:property name="content-encoding"
> default="ISO-8859-1" />">
> .....
> 
> <body ..>
> <% 
> try {
> 	String to = "******@****.com";
> 	String from = "******@****.com";
> 	String nome = "Nome : "+request.getParameter("nome");
> 
> 	Properties props = new Properties();
> 	props.put("mail.smtp.host", "smtp2.locaweb.com.br");
> 	Session session = Session.getInstance(props, null);
> 	
> 	MimeMessage message = new MimeMessage(session);
> 	
> 	message.setFrom(new
> InternetAddress(request.getParameter("email")));
> 	Address toAddress = new InternetAddress(to);
> 	message.addRecipient(Message.RecipientType.TO, toAddress);
> 	
> 	message.setSubject(request.getParameter("assunto"));
> 	
> 	message.setContent(nome+"\n" + "Mensagem :
> "+"\n"+request.getParameter("mensagem"), "text/plain");
> 	if (request.getParameter("email")!=null &
> request.getParameter("mensagem")!=null)
> 	Transport.send(message);
> 	out.println("<td class=\"content_title\"
> valign=\"top\">Sua mensagem foi enviada!</td>");
> }
> catch (MessagingException e) {
> 	out.println("<td class=\"content_title\"
> valign=\"top\">Email nao pode ser enviado!</td>");
> }
> 	out.println(new java.util.Date());
> %> 
> ...
> ...
> Please help
> =========================================================
> Zastedi 70% na razgovorite so stranstvo.
> 15 denari minuta za bilo koja zemja vo svetot.
> http://www.ozone.net.mk
> info telefon (02)3100.800 24h na den
> =========================================================
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
> 



More information about the opencms-dev mailing list