Index: /home/maurer/stuff/workspace/james-dev/src/java/org/apache/james/smtpserver/HeloCmdHandler.java
===================================================================
--- /home/maurer/stuff/workspace/james-dev/src/java/org/apache/james/smtpserver/HeloCmdHandler.java	(revision 392343)
+++ /home/maurer/stuff/workspace/james-dev/src/java/org/apache/james/smtpserver/HeloCmdHandler.java	(working copy)
@@ -40,6 +40,8 @@
      */
     private boolean checkValidHelo = false;
     
+    private boolean ignoreRelay = true;
+    
     /**
      * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
      */
@@ -48,6 +50,12 @@
         if(configuration != null) {
            checkValidHelo = configuration.getValueAsBoolean();
         }
+        
+        Configuration configRelay = handlerConfiguration.getChild("ignoreRelayClients",false);
+        if(configRelay != null) {
+            ignoreRelay = configRelay.getValueAsBoolean();
+        }
+        
     }
        
     /*
@@ -57,7 +65,6 @@
     **/
     public void onCommand(SMTPSession session) {
         doHELO(session, session.getCommandArgument());
-
     }
 
     /**
@@ -75,15 +82,22 @@
         
         // check for helo if its set in config
         if (checkValidHelo == true) {
-             
-            // try to resolv the provided helo. If it can not resolved do not accept it.
-            try {
-                org.apache.james.dnsserver.DNSServer.getByName(argument);
-            } catch (UnknownHostException e) {
-                badHelo = true;
-                responseString = "501 Provided HELO " + argument + " can not resolved";
-                session.writeResponse(responseString);
-                getLogger().info(responseString);
+            
+            /**
+             * don't check if the ip address is allowed to relay. Only check if it is set in the config. ed.
+             */
+            if (session.isRelayingAllowed() == false || ignoreRelay == false) {
+
+                // try to resolv the provided helo. If it can not resolved do not accept it.
+                try {
+                    org.apache.james.dnsserver.DNSServer.getByName(argument);
+                } catch (UnknownHostException e) {
+                    badHelo = true;
+                    responseString = "501 Provided HELO " + argument + " can not resolved";
+                    session.writeResponse(responseString);
+                    getLogger().info(responseString);
+                } 
+
             }
         }
         
@@ -107,8 +121,4 @@
             session.writeResponse(responseString);
         }
     }
-
-
-
-
 }
