View Javadoc

1   /*
2    * Copyright 2008 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.fatwire.gst.foundation.facade.runtag.mail;
18  
19  import COM.FutureTense.Interfaces.ICS;
20  import COM.FutureTense.Util.ftErrors;
21  
22  import com.fatwire.gst.foundation.facade.runtag.AbstractTagRunner;
23  
24  /**
25   * <mail.send to="recipient,recipient"
26   * <p/>
27   * [from="your e-mail"] [subject="subject of message"] [body="message body"]
28   * [replyto="your alternate e-mail address"] [contenttype="content format"]
29   * [charset="character set"] />
30   * 
31   * @author Tony Field
32   * @since 4-Nov-2008
33   */
34  public final class Send extends AbstractTagRunner {
35      public Send() {
36          super("mail.send");
37      }
38  
39      public void setTo(String commaSeparatedListOfEmailAddresses) {
40          set("to", commaSeparatedListOfEmailAddresses);
41      }
42  
43      public void setFrom(String from) {
44          set("from", from);
45      }
46  
47      public void setSubject(String subject) {
48          set("subject", subject);
49      }
50  
51      public void setBody(String body) {
52          set("body", body);
53      }
54  
55      public void setReplyto(String replyto) {
56          set("replyto", replyto);
57      }
58  
59      public void setContentType(String contentType) {
60          set("contenttype", contentType);
61      }
62  
63      public void setCharset(String charset) {
64          set("charset", charset);
65      }
66  
67      public static boolean sendMail(ICS ics, String to, String from, String subject, String body, String replyto,
68              String contentType, String charset) {
69          Send send = new Send();
70          send.setTo(to);
71          send.setFrom(from);
72          send.setSubject(subject);
73          send.setBody(body);
74          send.setReplyto(replyto);
75          send.setContentType(contentType);
76          send.setCharset(charset);
77          send.execute(ics);
78          return ics.GetErrno() != ftErrors.emailexception;
79      }
80  
81      public static boolean sendMail(ICS ics, String to, String subject, String body) {
82          return sendMail(ics, to, null, subject, body, null, null, null);
83      }
84  
85  }