jon 02/01/15 18:20:43
Modified: src/util/java/org/apache/fulcrum/template TemplateEmail.java
Log:
fixed bug where we didn't check to see if the CC was set.
also added more error checking
set null subject to ""
Revision Changes Path
1.4 +22 -6
jakarta-turbine-fulcrum/src/util/java/org/apache/fulcrum/template/TemplateEmail.java
Index: TemplateEmail.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine-fulcrum/src/util/java/org/apache/fulcrum/template/TemplateEmail.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TemplateEmail.java 15 Jan 2002 01:17:22 -0000 1.3
+++ TemplateEmail.java 16 Jan 2002 02:20:43 -0000 1.4
@@ -123,7 +123,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jon S. Stevens</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Greg Coladonato</a>
- * @version $Id: TemplateEmail.java,v 1.3 2002/01/15 01:17:22 jon Exp $
+ * @version $Id: TemplateEmail.java,v 1.4 2002/01/16 02:20:43 jon Exp $
*/
public class TemplateEmail
{
@@ -165,14 +165,14 @@
/**
* Constructor
*/
- public TemplateEmail ()
+ public TemplateEmail()
{
}
/**
* Constructor
*/
- public TemplateEmail (TemplateContext context)
+ public TemplateEmail(TemplateContext context)
{
this.context = context;
}
@@ -230,7 +230,14 @@
*/
public TemplateEmail setSubject(String subject)
{
- this.subject = subject;
+ if (subject == null)
+ {
+ this.subject = "";
+ }
+ else
+ {
+ this.subject = subject;
+ }
return (this);
}
@@ -289,11 +296,17 @@
}
/**
- * This method sends the email.
+ * This method sends the email. It will throw an exception
+ * if the To name or To Email values are null.
*/
public void send()
throws Exception
{
+ if (toEmail == null || toName == null)
+ {
+ throw new Exception ("Must set a To:");
+ }
+
// Process the template.
String body = TurbineTemplate.handleRequest(context,template);
@@ -308,7 +321,10 @@
SimpleEmail se = new SimpleEmail();
se.setFrom(fromEmail, fromName);
se.addTo(toEmail, toName);
- se.addCc(ccEmail, ccName);
+ if (ccEmail != null && ccName != null)
+ {
+ se.addCc(ccEmail, ccName);
+ }
se.setSubject(subject);
se.setMsg(body);
se.send();
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>