catch null envelopeTos
[org.ibex.mail.git] / src / org / ibex / mail / protocol / SMTP.java
index 8b27057..6d4aba2 100644 (file)
@@ -145,6 +145,10 @@ public class SMTP {
         }
 
         public static boolean attempt(Message m) throws IOException {
+            if (m.envelopeTo == null) {
+                Log.warn(SMTP.Outgoing.class, "aieeee, null envelopeTo: " + m.summary());
+                return false;
+            }
             InetAddress[] mx = getMailExchangerIPs(m.envelopeTo.host);
             if (mx.length == 0) {
                 Log.warn(SMTP.Outgoing.class, "could not resolve " + m.envelopeTo.host + "; bouncing it\n" + m.summary());
@@ -164,7 +168,7 @@ public class SMTP {
         }
 
         private static void check(String s, Connection conn) {
-            while (s.charAt(3) == '-') s = conn.readln();
+            while (s.length() > 3 && s.charAt(3) == '-') s = conn.readln();
             if (s.startsWith("4")||s.startsWith("5")) throw new SMTPException(s);
         }
         private static boolean attempt(final Message m, final InetAddress mx) {