mailing list improvements (and nntp)
[org.ibex.mail.git] / src / org / ibex / mail / protocol / SMTP.java
index 8d16b43..2ba9fdc 100644 (file)
@@ -73,7 +73,7 @@ public class SMTP {
             String remotehost = null;
             for(String command = conn.readln(); ; command = conn.readln()) try {
                 if (command == null) return;
-                Log.warn(conn.getRemoteAddress()+"", command);
+                Log.warn("**"+conn.getRemoteAddress()+"**", command);
                 String c = command.toUpperCase();
                 if (c.startsWith("HELO"))        {
                     remotehost = c.substring(5).trim();
@@ -99,6 +99,13 @@ public class SMTP {
                     command = command.substring(8).trim();
                     if(command.indexOf(' ') != -1) command = command.substring(0, command.indexOf(' '));
                     Address addr = new Address(command);
+                    /*
+                    Log.warn("**"+conn.getRemoteAddress()+"**",
+                             "addr.isLocal(): " + addr.isLocal() + "\n" +
+                             "conn.getRemoteAddress().isLoopbackAddress(): " + conn.getRemoteAddress().isLoopbackAddress() + "\n" +
+                             "johnw: " + (from!=null&&from.toString().indexOf("johnw")!=-1) + "\n"
+                             );
+                    */
                     if (addr.isLocal()) {
                         // FEATURE: should check the address further and give 550 if undeliverable
                         conn.println("250 " + addr + " is on this machine; I will deliver it");
@@ -364,6 +371,7 @@ public class SMTP {
                 ret = new InetAddress[1];
                 try {
                     ret[0] = InetAddress.getByName(hostName);
+                    if (ret[0].equals(IP.getIP(127,0,0,1)) || ret[0].isLoopbackAddress()) throw new UnknownHostException();
                     return ret;
                 } catch (UnknownHostException uhe) {
                     Log.warn(SMTP.class, "no MX hosts or A record for " + hostName);
@@ -378,7 +386,7 @@ public class SMTP {
                     mx = mx.substring(mx.indexOf(" ") + 1);
                     if (mx.charAt(mx.length() - 1) == '.') mx = mx.substring(0, mx.length() - 1);
                     InetAddress ia = InetAddress.getByName(mx);
-                    if (ia.equals(IP.getIP(127,0,0,1))) continue;
+                    if (ia.equals(IP.getIP(127,0,0,1)) || ia.isLoopbackAddress()) continue;
                     ret[i++] = ia;
                 }
             }