Send email

From OpenCms Wiki
Revision as of 16:00, 30 November 2009 by 87.159.170.224 (Talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Via the Opencms Mailing list, here's a simple scriptlet to send email from a JSP page:

<%@ 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(); 
%>

You must have the mail-element configured in opencms-system.xml:

 <mail>
  <mailfrom>something@somewhere.com</mailfrom>
  <mailhost name="your.smtp.server" protocol="smtp" user="username"
  password="secure"/>
  <mailhost name="main.smtp.server"/>
  <mailhost name="failover.smtp.server"/>
 </mail>
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox