--- src/java/org/apache/james/smtpserver/HeloCmdHandler.java	2006-01-03 09:51:21.000000000 +0100
+++ src/java/org/apache/james/smtpserver/HeloCmdHandlerNew.java	2006-03-26 19:35:56.000000000 +0200
@@ -17,10 +17,18 @@
 
 package org.apache.james.smtpserver;
 
+
+import java.net.UnknownHostException;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+
+
 /**
   * Handles HELO command
   */
-public class HeloCmdHandler implements CommandHandler {
+public class HeloCmdHandlerNew extends AbstractLogEnabled implements CommandHandler,Configurable {
 
     /**
      * The name of the command handled by the command handler
@@ -32,6 +40,21 @@
      */
     private final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; // HELO or EHLO
 
+    /**
+     * set checkValidHelo to false as default value
+     */
+    private boolean checkValidHelo = false;
+    
+    /**
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
+     */
+    public void configure(Configuration handlerConfiguration) throws ConfigurationException {
+        Configuration configuration = handlerConfiguration.getChild("checkValidHelo",false);
+        if(configuration != null) {
+           checkValidHelo = configuration.getValueAsBoolean();
+        }
+    }
+       
     /*
      * process HELO command
      *
@@ -52,10 +75,28 @@
      */
     private void doHELO(SMTPSession session, String argument) {
         String responseString = null;
+        boolean badHelo = false;
+                
+        
+        // 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 Helo can not resolved";
+                session.writeResponse(responseString);
+                getLogger().info(responseString);
+            }
+        }
+        
         if (argument == null) {
             responseString = "501 Domain address required: " + COMMAND_NAME;
             session.writeResponse(responseString);
-        } else {
+            getLogger().info(responseString);
+        } else if (badHelo == false) {
             session.resetState();
             session.getState().put(CURRENT_HELO_MODE, COMMAND_NAME);
             session.getResponseBuffer().append("250 ")
--- src/conf/james-config.xml	2005-12-29 11:03:28.000000000 +0100
+++ src/conf/james-configNEW.xml	2006-03-26 20:09:38.000000000 +0200
@@ -706,7 +706,12 @@
             -->            
             
             <!-- The command handler configuration -->
-            <handler command="HELO" class="org.apache.james.smtpserver.HeloCmdHandler"></handler>
+            
+            <handler command="HELO" class="org.apache.james.smtpserver.HeloCmdHandler"
+            <!-- If is set to true helo is only accepted if it can be resolved --> 
+                <checkValidHelo> false </checkValidHelo>
+            </handler>
+            
             <handler command="EHLO" class="org.apache.james.smtpserver.EhloCmdHandler"></handler>
             <handler command="AUTH" class="org.apache.james.smtpserver.AuthCmdHandler"></handler>
             <handler command="VRFY" class="org.apache.james.smtpserver.VrfyCmdHandler"></handler>
