minor refactoring in SMTP
[org.ibex.mail.git] / src / org / ibex / mail / SMTP.java
index bf162fb..a23c7de 100644 (file)
@@ -185,6 +185,11 @@ public class SMTP {
                     } else if (conn.getRemoteAddress().isLoopbackAddress() || (from!=null&&from.toString().indexOf("johnw")!=-1)) {
                         conn.println("250 you are connected locally, so I will let you send");
                         to.addElement(addr);
+                        whitelist.addWhitelist(addr);
+                    } else if (authenticatedAs!=null) {
+                        conn.println("250 you are authenticated as "+authenticatedAs+", so I will let you send");
+                        to.addElement(addr);
+                        whitelist.addWhitelist(addr);
                     } else {
                         conn.println("535 sorry, " + addr + " is not on this machine, you are not connected from localhost, and I will not relay without SMTP AUTH");
                         Log.warn("","535 sorry, " + addr + " is not on this machine, you are not connected from localhost, and I will not relay without SMTP AUTH");
@@ -339,15 +344,11 @@ public class SMTP {
                     conn.println("HELO " + conn.vhost);
                     check(conn.readln(), conn);
                 }
-                if (m.envelopeFrom==null) {
-                    Log.warn("", "MAIL FROM:<>");
-                    conn.println("MAIL FROM:<>");  check(conn.readln(), conn);
-                } else {
-                    Log.warn("", "MAIL FROM:<" + m.envelopeFrom.toString()+">");
-                    conn.println("MAIL FROM:<" + m.envelopeFrom.toString()+">");  check(conn.readln(), conn);
-                }
-                conn.println("RCPT TO:<"   + m.envelopeTo.toString()+">");      check(conn.readln(), conn);
-                conn.println("DATA");                          check(conn.readln(), conn);
+                String envelopeFrom = m.envelopeFrom==null ? "" : m.envelopeFrom.toString();
+                conn.println("MAIL FROM:<" + envelopeFrom +">");            check(conn.readln(), conn);
+                conn.println("RCPT TO:<"   + m.envelopeTo.toString()+">");  check(conn.readln(), conn);
+                conn.println("DATA");                                       check(conn.readln(), conn);
+
                 Headers head = m.headers;
                 head = head.remove("return-path");
                 head = head.remove("bcc");