You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by bs...@apache.org on 2006/02/07 09:40:19 UTC
svn commit: r375548 -
/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java
Author: bsnyder
Date: Tue Feb 7 00:40:18 2006
New Revision: 375548
URL: http://svn.apache.org/viewcvs?rev=375548&view=rev
Log:
Had to apply a few fixes to the SMTPTransport class.
Modified:
geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java
Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java?rev=375548&r1=375547&r2=375548&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java Tue Feb 7 00:40:18 2006
@@ -25,7 +25,6 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.InetAddress;
-import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
@@ -340,16 +339,6 @@
debugOut("I/O exception establishing connection", e);
}
throw new MessagingException("Connection error", e);
- } catch (SMTPTransportException e) {
- if (debug) {
- debugOut("Exception establishing connection", e);
- }
- throw new MessagingException("error", e);
- } catch (MalformedSMTPReplyException e) {
- if (debug) {
- debugOut("Exception establishing connection", e);
- }
- throw new MessagingException("error", e);
}
return true;
}
@@ -1265,9 +1254,9 @@
msg.writeTo(outputStream);
outputStream.flush();
} catch (IOException e) {
- throw new SMTPTransportException(e);
+ throw new MessagingException(e.toString());
} catch (MessagingException e) {
- throw new SMTPTransportException(e);
+ throw new MessagingException(e.toString());
}
// now to finish, we send a CRLF sequence, followed by a ".".
@@ -1275,7 +1264,13 @@
sendLine(".");
// use a longer time out here to give the server time to process the data.
- line = new SMTPReply(receiveLine(TIMEOUT * 2));
+ try {
+ line = new SMTPReply(receiveLine(TIMEOUT * 2));
+ } catch (MalformedSMTPReplyException e) {
+ throw new MessagingException(e.toString());
+ } catch (MessagingException e) {
+ throw new MessagingException(e.toString());
+ }
return !line.isError();
}
@@ -1397,7 +1392,7 @@
if (from == null || from.length() == 0) {
- throw new SMTPTransportException("no FROM address");
+ throw new MessagingException("no FROM address");
}
StringBuffer command = new StringBuffer();
@@ -1515,7 +1510,7 @@
debugOut("sending line to server >>>" + data + "<<<");
}
if (socket == null || !socket.isConnected()) {
- throw new SMTPTransportException("no connection");
+ throw new MessagingException("no connection");
}
try {
outputStream.write(data.getBytes());
@@ -1523,7 +1518,7 @@
outputStream.write(LF);
outputStream.flush();
} catch (IOException e) {
- throw new SMTPTransportException(e);
+ throw new MessagingException(e.toString());
}
}
@@ -1543,7 +1538,13 @@
* @return An SMTP reply object from the stream.
*/
protected SMTPReply getReply() throws MessagingException {
- lastServerResponse = new SMTPReply(receiveLine());
+ try {
+ lastServerResponse = new SMTPReply(receiveLine());
+ } catch (MalformedSMTPReplyException e) {
+ throw new MessagingException(e.toString());
+ } catch (MessagingException e) {
+ throw e;
+ }
return lastServerResponse;
}
@@ -1570,7 +1571,7 @@
*/
protected String receiveLine(int delayMillis) throws MessagingException {
if (socket == null || !socket.isConnected()) {
- throw new SMTPTransportException("no connection");
+ throw new MessagingException("no connection");
}
int timeout = 0;
@@ -1608,9 +1609,9 @@
return line;
} catch (SocketException e) {
- throw new SMTPTransportException(e);
+ throw new MessagingException(e.toString());
} catch (IOException e) {
- throw new SMTPTransportException(e);
+ throw new MessagingException(e.toString());
} finally {
try {
socket.setSoTimeout(timeout);
@@ -1760,7 +1761,7 @@
}
if (localHost == null) {
- throw new SMTPTransportException("Can't get local hostname. " +
+ throw new MessagingException("Can't get local hostname. " +
" Please correctly configure JDK/DNS or set mail.smtp.localhost");
}
}
@@ -2014,7 +2015,14 @@
// authentication, and a 334 indicates we have an additional challenge.
while (true) {
// get the next line, and if it is an error response, return now.
- SMTPReply line = new SMTPReply(receiveLine());
+ SMTPReply line;
+ try {
+ line = new SMTPReply(receiveLine());
+ } catch (MalformedSMTPReplyException e) {
+ throw new MessagingException(e.toString());
+ } catch (MessagingException e) {
+ throw e;
+ }
// if we get a completion return, we've passed muster, so give an authentication response.
if (line.getCode() == AUTHENTICATION_COMPLETE) {