You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ri...@apache.org on 2006/06/14 12:18:55 UTC
svn commit: r414173 [5/7] - in /geronimo/javamail/trunk: ./
javamail-provider-1.3/ javamail-provider-1.3/src/
javamail-provider-1.3/src/java/ javamail-provider-1.3/src/java/org/
javamail-provider-1.3/src/java/org/apache/ javamail-provider-1.3/src/java/...
Added: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPMessage.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPMessage.java?rev=414173&view=auto
==============================================================================
--- geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPMessage.java (added)
+++ geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPMessage.java Wed Jun 14 03:18:51 2006
@@ -0,0 +1,235 @@
+/**
+ *
+ * Copyright 2003-2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.javamail.transport.smtp;
+
+import java.io.InputStream;
+
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.MimeMessage;
+
+public class SMTPMessage extends MimeMessage {
+
+ // never notify
+ public static final int NOTIFY_NEVER = -1;
+
+ // notify of successful deliveries.
+ public static final int NOTIFY_SUCCESS = 1;
+
+ // notify of delivery failures.
+ public static final int NOTIFY_FAILURE = 2;
+
+ // notify of delivery delays
+ public static final int NOTIFY_DELAY = 4;
+
+ // return full message with status notifications
+ public static final int RETURN_FULL = 1;
+
+ // return only message headers with status notifications
+ public static final int RETURN_HDRS = 2;
+
+ // support 8BitMime encodings
+ protected boolean allow8bitMIME = false;
+
+ // a from address specified in the message envelope. Overrides other from
+ // sources.
+ protected String envelopeFrom = null;
+
+ // an option string to append to the MAIL command on sending.
+ protected String mailExtension = null;
+
+ // SMTP mail notification options if DSN is supported.
+ protected int notifyOptions = 0;
+
+ // DSN return option notification values.
+ protected int returnOption = 0;
+
+ // allow sending if some addresses give errors.
+ protected boolean sendPartial = false;
+
+ // an RFC 2554 AUTH= value.
+ protected String submitter = null;
+
+ /**
+ * Default (and normal) constructor for an SMTPMessage.
+ *
+ * @param session
+ * The hosting Javamail Session.
+ */
+ public SMTPMessage(Session session) {
+ // this is a simple one.
+ super(session);
+ }
+
+ /**
+ * Construct an SMTPMessage instance by reading and parsing the data from
+ * the provided InputStream. The InputStream will be left positioned at the
+ * end of the message data on constructor completion.
+ *
+ * @param session
+ * The hosting Javamail Session.
+ */
+ public SMTPMessage(Session session, InputStream source) throws MessagingException {
+ // this is a simple one.
+ super(session, source);
+ }
+
+ /**
+ * Construct an SMTPMimeMessage from another source MimeMessage object. The
+ * new object and the old object are independent of each other.
+ *
+ * @param source
+ * The source MimeMessage object.
+ */
+ public SMTPMessage(MimeMessage source) throws MessagingException {
+ super(source);
+ }
+
+ /**
+ * Change the allow8BitMime attribute for the message.
+ *
+ * @param a
+ * The new setting.
+ */
+ public void setAllow8bitMIME(boolean a) {
+ allow8bitMIME = a;
+ }
+
+ /**
+ * Retrieve the current 8bitMIME attribute.
+ *
+ * @return The current attribute value.
+ */
+ public boolean getAllow8bitMIME() {
+ return allow8bitMIME;
+ }
+
+ /**
+ * Change the envelopeFrom attribute for the message.
+ *
+ * @param from
+ * The new setting.
+ */
+ public void setEnvelopeFrom(String from) {
+ envelopeFrom = from;
+ }
+
+ /**
+ * Retrieve the current evelopeFrom attribute.
+ *
+ * @return The current attribute value.
+ */
+ public String getEnvelopeFrom() {
+ return envelopeFrom;
+ }
+
+ /**
+ * Change the mailExtension attribute for the message.
+ *
+ * @param e
+ * The new setting.
+ */
+ public void setMailExtension(String e) {
+ mailExtension = e;
+ }
+
+ /**
+ * Retrieve the current mailExtension attribute.
+ *
+ * @return The current attribute value.
+ */
+ public String getMailExtension() {
+ return mailExtension;
+ }
+
+ /**
+ * Change the notifyOptions attribute for the message.
+ *
+ * @param options
+ * The new setting.
+ */
+ public void setNotifyOptions(int options) {
+ notifyOptions = options;
+ }
+
+ /**
+ * Retrieve the current notifyOptions attribute.
+ *
+ * @return The current attribute value.
+ */
+ public int getNotifyOptions() {
+ return notifyOptions;
+ }
+
+ /**
+ * Change the returnOptions attribute for the message.
+ *
+ * @param option
+ * The new setting.
+ */
+ public void setReturnOption(int option) {
+ returnOption = option;
+ }
+
+ /**
+ * Retrieve the current returnOption attribute.
+ *
+ * @return The current attribute value.
+ */
+ public int getReturnOption() {
+ return returnOption;
+ }
+
+ /**
+ * Change the sendPartial attribute for the message.
+ *
+ * @param a
+ * The new setting.
+ */
+ public void setSendPartial(boolean a) {
+ sendPartial = a;
+ }
+
+ /**
+ * Retrieve the current sendPartial attribute.
+ *
+ * @return The current attribute value.
+ */
+ public boolean getSendPartial() {
+ return sendPartial;
+ }
+
+ /**
+ * Change the submitter attribute for the message.
+ *
+ * @param s
+ * The new setting.
+ */
+ public void setSubmitter(String s) {
+ submitter = s;
+ }
+
+ /**
+ * Retrieve the current submitter attribute.
+ *
+ * @return The current attribute value.
+ */
+ public String getSubmitter() {
+ return submitter;
+ }
+}
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPMessage.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPMessage.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPReply.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPReply.java?rev=414173&view=auto
==============================================================================
--- geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPReply.java (added)
+++ geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPReply.java Wed Jun 14 03:18:51 2006
@@ -0,0 +1,123 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.javamail.transport.smtp;
+
+/**
+ * Util class to represent a reply from a SMTP server
+ *
+ * @version $Rev$ $Date$
+ */
+class SMTPReply {
+ // The original reply string
+ private final String reply;
+
+ // returned message code
+ private final int code;
+
+ // the returned message text
+ private final String message;
+
+ // indicates that this is a continuation response
+ private boolean continued;
+
+ SMTPReply(String s) throws MalformedSMTPReplyException {
+ // save the reply
+ reply = s;
+
+ // In a normal response, the first 3 must be the return code. However,
+ // the response back from a QUIT command is frequently a null string.
+ // Therefore, if the result is
+ // too short, just default the code to -1 and use the entire text for
+ // the message.
+ if (s == null || s.length() < 3) {
+ code = -1;
+ message = s;
+ return;
+ }
+
+ try {
+ continued = false;
+ code = Integer.parseInt(s.substring(0, 3));
+
+ // message should be separated by a space OR a continuation
+ // character if this is a
+ // multi-line response.
+ if (s.length() > 4) {
+ //
+ if (s.charAt(3) == '-') {
+ continued = true;
+ }
+ message = s.substring(4);
+ } else {
+ message = "";
+ }
+ } catch (NumberFormatException e) {
+ throw new MalformedSMTPReplyException("error in parsing code", e);
+ }
+ }
+
+ /**
+ * Return the code value associated with the reply.
+ *
+ * @return The integer code associated with the reply.
+ */
+ public int getCode() {
+ return this.code;
+ }
+
+ /**
+ * Get the message text associated with the reply.
+ *
+ * @return The string value of the message from the reply.
+ */
+ public String getMessage() {
+ return this.message;
+ }
+
+ /**
+ * Retrieve the raw reply string for the reponse.
+ *
+ * @return The original reply string from the server.
+ */
+ public String getReply() {
+ return reply;
+ }
+
+ /**
+ * Indicates if reply is an error condition
+ */
+ boolean isError() {
+ // error codes are all above 400
+ return code >= 400;
+ }
+
+ /**
+ * Indicates whether this response is flagged as part of a multiple line
+ * response.
+ *
+ * @return true if the response has multiple lines, false if this is the
+ * last line of the response.
+ */
+ public boolean isContinued() {
+ return continued;
+ }
+
+ public String toString() {
+ return "CODE = " + getCode() + " : MSG = " + getMessage();
+ }
+}
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPReply.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPReply.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPReply.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSTransport.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSTransport.java?rev=414173&view=auto
==============================================================================
--- geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSTransport.java (added)
+++ geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSTransport.java Wed Jun 14 03:18:51 2006
@@ -0,0 +1,31 @@
+/**
+ *
+ * Copyright 2003-2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.javamail.transport.smtp;
+
+import javax.mail.Session;
+import javax.mail.URLName;
+
+public class SMTPSTransport extends SMTPTransport {
+ /**
+ * @param session
+ * @param name
+ */
+ public SMTPSTransport(Session session, URLName name) {
+ super(session, name, "smtps", 465, true);
+ }
+}
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSTransport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSTransport.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSTransport.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSendFailedException.java
URL: http://svn.apache.org/viewvc/geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSendFailedException.java?rev=414173&view=auto
==============================================================================
--- geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSendFailedException.java (added)
+++ geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSendFailedException.java Wed Jun 14 03:18:51 2006
@@ -0,0 +1,72 @@
+/**
+ *
+ * Copyright 2003-2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.javamail.transport.smtp;
+
+import javax.mail.Address;
+import javax.mail.SendFailedException;
+
+public class SMTPSendFailedException extends SendFailedException {
+ // the failing command
+ protected String cmd;
+
+ // the error code for the failure
+ protected int rc;
+
+ /**
+ * Constructor for an SMTPSendFaileException.
+ *
+ * @param cmd
+ * The failing command string.
+ * @param rc
+ * The error code for the failing command.
+ * @param err
+ * An error message for the exception.
+ * @param ex
+ * Any associated nested exception.
+ * @param vs
+ * An array of valid, sent addresses.
+ * @param vus
+ * An array of addresses that were valid, but were unsent.
+ * @param inv
+ * An array of addresses deemed invalid.
+ */
+ SMTPSendFailedException(java.lang.String cmd, int rc, java.lang.String err, java.lang.Exception ex, Address[] vs,
+ Address[] vus, Address[] inv) {
+ super(err, ex, vs, vus, inv);
+ this.cmd = cmd;
+ this.rc = rc;
+ }
+
+ /**
+ * Get the failing command string for the exception.
+ *
+ * @return The string value of the failing command.
+ */
+ public String getCommand() {
+ return cmd;
+ }
+
+ /**
+ * The failing command return code.
+ *
+ * @return The failure return code.
+ */
+ public int getReturnCode() {
+ return rc;
+ }
+}
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSendFailedException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSendFailedException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/javamail/trunk/javamail-provider-1.3/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPSendFailedException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain