1 21 22 27 28 package com.sun.mail.smtp; 29 30 import java.io.*; 31 import javax.mail.*; 32 import javax.mail.internet.*; 33 34 47 48 public class SMTPMessage extends MimeMessage { 49 50 51 public static final int NOTIFY_NEVER = -1; 52 53 public static final int NOTIFY_SUCCESS = 1; 54 55 public static final int NOTIFY_FAILURE = 2; 56 57 public static final int NOTIFY_DELAY = 4; 58 59 60 public static final int RETURN_FULL = 1; 61 62 public static final int RETURN_HDRS = 2; 63 64 private static final String [] returnOptionString = { null, "FULL", "HDRS" }; 65 66 private String envelopeFrom; private int notifyOptions = 0; 68 private int returnOption = 0; 69 private boolean sendPartial = false; 70 private boolean allow8bitMIME = false; 71 private String submitter = null; private String extension = null; 74 80 public SMTPMessage(Session session) { 81 super(session); 82 } 83 84 94 public SMTPMessage(Session session, InputStream is) 95 throws MessagingException { 96 super(session, is); 97 } 98 99 110 public SMTPMessage(MimeMessage source) throws MessagingException { 111 super(source); 112 } 113 114 125 public void setEnvelopeFrom(String from) { 126 envelopeFrom = from; 127 } 128 129 134 public String getEnvelopeFrom() { 135 return envelopeFrom; 136 } 137 138 150 public void setNotifyOptions(int options) { 151 if (options < -1 || options >= 8) 152 throw new IllegalArgumentException ("Bad return option"); 153 notifyOptions = options; 154 } 155 156 161 public int getNotifyOptions() { 162 return notifyOptions; 163 } 164 165 169 String getDSNNotify() { 170 if (notifyOptions == 0) 171 return null; 172 if (notifyOptions == NOTIFY_NEVER) 173 return "NEVER"; 174 StringBuffer sb = new StringBuffer (); 175 if ((notifyOptions & NOTIFY_SUCCESS) != 0) 176 sb.append("SUCCESS"); 177 if ((notifyOptions & NOTIFY_FAILURE) != 0) { 178 if (sb.length() != 0) 179 sb.append(','); 180 sb.append("FAILURE"); 181 } 182 if ((notifyOptions & NOTIFY_DELAY) != 0) { 183 if (sb.length() != 0) 184 sb.append(','); 185 sb.append("DELAY"); 186 } 187 return sb.toString(); 188 } 189 190 200 public void setReturnOption(int option) { 201 if (option < 0 || option > RETURN_HDRS) 202 throw new IllegalArgumentException ("Bad return option"); 203 returnOption = option; 204 } 205 206 211 public int getReturnOption() { 212 return returnOption; 213 } 214 215 219 String getDSNRet() { 220 return returnOptionString[returnOption]; 221 } 222 223 233 public void setAllow8bitMIME(boolean allow) { 234 allow8bitMIME = allow; 235 } 236 237 242 public boolean getAllow8bitMIME() { 243 return allow8bitMIME; 244 } 245 246 257 public void setSendPartial(boolean partial) { 258 sendPartial = partial; 259 } 260 261 266 public boolean getSendPartial() { 267 return sendPartial; 268 } 269 270 276 public String getSubmitter() { 277 return submitter; 278 } 279 280 290 public void setSubmitter(String submitter) { 291 this.submitter = submitter; 292 } 293 294 301 public String getMailExtension() { 302 return extension; 303 } 304 305 326 public void setMailExtension(String extension) { 327 this.extension = extension; 328 } 329 } 330 | Popular Tags |