Index: src/java/org/apache/log4j/net/SMTPAppender.java =================================================================== RCS file: /home/cvspublic/jakarta-log4j/src/java/org/apache/log4j/net/SMTPAppender.java,v retrieving revision 1.31 diff -u -r1.31 SMTPAppender.java --- src/java/org/apache/log4j/net/SMTPAppender.java 18 Mar 2003 13:33:32 -0000 1.31 +++ src/java/org/apache/log4j/net/SMTPAppender.java 18 Apr 2003 17:24:16 -0000 @@ -43,10 +43,38 @@ @author Ceki Gülcü @since 1.0 */ public class SMTPAppender extends AppenderSkeleton { + /** + * Comma seperated list of email addresses for the To line. + */ private String to; + /** + * Comma seperated list of email addresses for the Cc line. + */ + private String cc; + /** + * Email addresses for the From line (also becomes the reply-to). + */ private String from; + /** + * Email subject line value. + */ private String subject; + /** + * Email server to use to send messages. + */ private String smtpHost; + + /** + * Email header used to set messages to higher or lower priority given a numerical value of 1 through 5. + *
    + *
  1. Highest Priority
  2. + *
  3. High Priority
  4. + *
  5. Normal (default if not defined)
  6. + *
  7. Low Priority
  8. + *
  9. Lowest Priority
  10. + *
+ */ + private int priority = 3; private int bufferSize = 512; private boolean locationInfo = false; @@ -92,15 +120,25 @@ try { if (from != null) - msg.setFrom(getAddress(from)); + msg.setFrom(getAddress(from)); else - msg.setFrom(); + msg.setFrom(); msg.setRecipients(Message.RecipientType.TO, parseAddress(to)); + + //Add CC receipients if defined. + if (cc != null && !"".equals(cc)) { + msg.setRecipients(Message.RecipientType.CC, parseAddress(cc)); + } + + //Set email priority + msg.addHeader("X-Priority", String.valueOf(getPriority())); + + //Add Subject if present if(subject != null) - msg.setSubject(subject); + msg.setSubject(subject); } catch(MessagingException e) { - LogLog.error("Could not activate SMTPAppender options.", e ); + LogLog.error("Could not activate SMTPAppender options.", e ); } } @@ -180,14 +218,6 @@ } } - /** - Returns value of the To option. - */ - public - String getTo() { - return to; - } - /** The SMTPAppender requires a {@link @@ -242,7 +272,20 @@ } } - + /** + The EvaluatorClass option takes a string value + representing the name of the class implementing the {@link + TriggeringEventEvaluator} interface. A corresponding object will + be instantiated and assigned as the triggering event evaluator + for the SMTPAppender. + */ + public + void setEvaluatorClass(String value) { + evaluator = (TriggeringEventEvaluator) + OptionConverter.instantiateByClassName(value, + TriggeringEventEvaluator.class, + evaluator); + } /** Returns value of the EvaluatorClass option. @@ -253,11 +296,12 @@ } /** - Returns value of the From option. + The Subject option takes a string value which should be a + the subject of the e-mail message. */ public - String getFrom() { - return from; + void setSubject(String subject) { + this.subject = subject; } /** @@ -278,15 +322,13 @@ } /** - The Subject option takes a string value which should be a - the subject of the e-mail message. + Returns value of the From option. */ public - void setSubject(String subject) { - this.subject = subject; + String getFrom() { + return from; } - /** The BufferSize option takes a positive integer representing the maximum number of logging events to collect in a @@ -301,6 +343,14 @@ } /** + Returns value of the BufferSize option. + */ + public + int getBufferSize() { + return bufferSize; + } + + /** The SMTPHost option takes a string value which should be a the host name of the SMTP server that will send the e-mail message. */ @@ -326,31 +376,47 @@ this.to = to; } + /** + Returns value of the To option. + */ + public + String getTo() { + return to; + } + /** + The Cc option takes a string value which should be a + comma separated list of e-mail address of the recipients. + */ + public + void setCc(String cc) { + this.cc = cc; + } /** - Returns value of the BufferSize option. + Returns value of the Cc option. */ public - int getBufferSize() { - return bufferSize; + String getCc() { + return cc; } /** - The EvaluatorClass option takes a string value - representing the name of the class implementing the {@link - TriggeringEventEvaluator} interface. A corresponding object will - be instantiated and assigned as the triggering event evaluator - for the SMTPAppender. + The Priority option takes a positive integer (1 through 5) + representing the priority of the email message. Default is 3 (aka normal). */ public - void setEvaluatorClass(String value) { - evaluator = (TriggeringEventEvaluator) - OptionConverter.instantiateByClassName(value, - TriggeringEventEvaluator.class, - evaluator); + void setPriority(int priority) { + this.priority = priority; } + /** + Returns value of the Priority option. + */ + public + int getPriority() { + return priority; + } /** The LocationInfo option takes a boolean value. By