001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package mx4j.tools.mail;
010:
011: import javax.management.ObjectName;
012:
013: /**
014: * Management Interface of a SMTP MBean.
015: * <p/>
016: * This MBean is meant to send a mail given certain situation. It may be used to listen to a monitor
017: * or timer and send a mail.
018: * <p/>
019: * To use it you need to add to your classpath the mail.jar from the JavaMail API and the activation.jar
020: * from the Java Activation Framework.
021: * <p/>
022: * Besides you need to configure all the required fields, at least the serverHost and To fields and if your server
023: * requires login also the serverUsername and serverPassword fields
024: * <p/>
025: * The subject and content fields are subject to keyword expansions, i.e. some keyworks put between $ signs will
026: * be exapnded this can be used to give a more informative message. The current available expansions are
027: * <p/>
028: * $date$ -> Current date formatted with locale format
029: * $time$ -> Current tim formatted with locale format
030: * $datetime$ -> Current date and time formatted with locale format
031: * $notification$ -> Notification type
032: * $observed$ -> ObjectName of the observed object
033: * $objectname$ -> This MBean's objectname
034: *
035: * @version $Revision: 1.4 $
036: */
037: public interface SMTPMBean {
038: /**
039: * Gets the MBean's objectname which is being listened
040: */
041: public ObjectName getObservedObject();
042:
043: /**
044: * Sets the observed object. It is expected that the observed MBean is a NotificationBroadcster
045: * On the contrary the MBean will not be listening to events
046: */
047: public void setObservedObject(ObjectName targetMBeanName);
048:
049: /**
050: * Returns the notification which will trigger the mail sending
051: */
052: public String getNotificationName();
053:
054: /**
055: * Sets the notification name which will trigger the mail sending. If it is null any notification
056: * will trigger a mail
057: */
058: public void setNotificationName(String notificationName);
059:
060: /**
061: * Gets the server's host as name or IP
062: */
063: public String getServerHost();
064:
065: /**
066: * Sets the server's host, it can be set as name or IP
067: */
068: public void setServerHost(String host);
069:
070: /**
071: * Sets the server's port.
072: */
073: public void setServerPort(int port);
074:
075: /**
076: * Gets the server's port, by default is 25
077: */
078: public int getServerPort();
079:
080: /**
081: * Sets server's username, use with setLoginToServer(true)
082: */
083: public void setServerUsername(String username);
084:
085: /**
086: * Gets the username to log to the server
087: */
088: public String getServerUsername();
089:
090: /**
091: * Sets server's passowrd, use with setLoginToServer(true) and setServerUsername
092: */
093: public void setServerPassword(String password);
094:
095: /**
096: * Sets whether to login to the SMTP server
097: */
098: public void setLoginToServer(boolean login);
099:
100: /**
101: * Indicates whether login to the SMTP server will be attpemted
102: */
103: public boolean isLoginToServer();
104:
105: /**
106: * Sets the send timeout, by default it is 10 secs
107: */
108: public void setTimeout(int timeout);
109:
110: /**
111: * Returns the timeout used when sending mails
112: */
113: public int getTimeout();
114:
115: /**
116: * Gets the from address attached to mails
117: */
118: public String getFromAddress();
119:
120: /**
121: * Sets the form address set to mail
122: */
123: public void setFromAddress(String fromAddress);
124:
125: /**
126: * Gets the from name presented on the mail
127: */
128: public String getFromName();
129:
130: /**
131: * Sets the from name presented on the mail
132: */
133: public void setFromName(String fromName);
134:
135: /**
136: * Gets the MIME type set to the mail
137: */
138: public String getMimeType();
139:
140: /**
141: * Sets the MIME type, by default it is text/plain
142: */
143: public void setMimeType(String mimeType);
144:
145: /**
146: * Gets a comma separated list of addresses set in the TO field
147: */
148: public String getTo();
149:
150: /**
151: * Sets a comma separated list of address which will go in the TO mail field
152: */
153: public void setTo(String toAddresses);
154:
155: /**
156: * Gets a comma separated list of addresses set in the BCC field
157: */
158: public String getBCC();
159:
160: /**
161: * Sets a comma separated list of address which will go in the BCC mail field
162: */
163: public void setBCC(String bccAddresses);
164:
165: /**
166: * Gets a comma separated list of addresses set in the CC field
167: */
168: public String getCC();
169:
170: /**
171: * Sets a comma separated list of address which will go in the CC mail field
172: */
173: public void setCC(String ccAddresses);
174:
175: /**
176: * Gets the mail subject
177: */
178: public String getSubject();
179:
180: /**
181: * Sets the mail's subject, by default is Empty subject. The subject field can contain keyword expansion
182: */
183: public void setSubject(String subject);
184:
185: /**
186: * Returns the content of the mail
187: */
188: public String getContent();
189:
190: /**
191: * Sets the content of the mail
192: */
193: public void setContent(String content);
194:
195: /**
196: * This will directly execute the send mail. It can be used to manually testing the MBean or direct execution
197: */
198: public void sendMail();
199:
200: }
|