Send email

From OpenCms Wiki
(Difference between revisions)
Jump to: navigation, search
 
 
(One intermediate revision by one user not shown)
Line 1: Line 1:
 
Via the [http://mail.opencms.org/pipermail/opencms-dev/2005q3/019104.html Opencms Mailing list], here's a simple scriptlet to send email from a JSP page:
 
Via the [http://mail.opencms.org/pipermail/opencms-dev/2005q3/019104.html Opencms Mailing list], here's a simple scriptlet to send email from a JSP page:
 
+
<code lang="java">
<pre>
+
 
<%@ page import="org.opencms.mail.CmsSimpleMail" %>
 
<%@ page import="org.opencms.mail.CmsSimpleMail" %>
 
<% CmsSimpleMail sm = new CmsSimpleMail();
 
<% CmsSimpleMail sm = new CmsSimpleMail();
Line 9: Line 8:
 
  sm.send();  
 
  sm.send();  
 
%>
 
%>
</pre>
+
</code>
 +
 
 +
You must have the mail-element configured in opencms-system.xml:
 +
<code lang="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>
 +
</code>
 +
{{stub}}

Latest revision as of 16:00, 30 November 2009

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