Index: container-spring/src/main/config/examples/domainlist.xml
===================================================================
--- container-spring/src/main/config/examples/domainlist.xml	(revision 1035153)
+++ container-spring/src/main/config/examples/domainlist.xml	(working copy)
@@ -45,6 +45,7 @@
     </domainnames>
     <autodetect>true</autodetect>
     <autodetectIP>true</autodetectIP>
+    <defaultDomain>localhost</defaultDomain>
   </domainlist>
   
   <!-- JPA implementation for DomainList -->
@@ -52,6 +53,7 @@
   <domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
     <autodetect>true</autodetect>
     <autodetectIP>true</autodetectIP>
+    <defaultDomain>localhost</defaultDomain>
   </domainlist>
   -->
   
@@ -63,6 +65,7 @@
     <sqlFile>file://conf/sqlResources.xml</sqlFile>
     <autodetect>true</autodetect>
     <autodetectIP>true</autodetectIP>
+    <defaultDomain>localhost</defaultDomain>
   </domainlist>  
   -->
 </domainlists>
Index: container-spring/src/main/config/examples/mailetcontainer.xml
===================================================================
--- container-spring/src/main/config/examples/mailetcontainer.xml	(revision 1035153)
+++ container-spring/src/main/config/examples/mailetcontainer.xml	(working copy)
@@ -19,6 +19,9 @@
  --> 
 <!-- This block is responsible for processing messages on the spool. -->
  <mailetcontainer>
+      <!-- MailAddress used for PostMaster -->
+      <postmaster>Postmaster@localhost</postmaster>
+
       <!-- Number of spool threads -->
       <threads> 20 </threads>
 
Index: container-spring/src/main/config/examples/mailserver.xml
===================================================================
--- container-spring/src/main/config/examples/mailserver.xml	(revision 1035153)
+++ container-spring/src/main/config/examples/mailserver.xml	(working copy)
@@ -1,43 +0,0 @@
-<?xml version="1.0"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one   
-  or more contributor license agreements.  See the NOTICE file 
-  distributed with this work for additional information        
-  regarding copyright ownership.  The ASF licenses this file   
-  to you under the Apache License, Version 2.0 (the            
-  "License"); you may not use this file except in compliance   
-  with the License.  You may obtain a copy of the License at   
-                                                               
-    http://www.apache.org/licenses/LICENSE-2.0                 
-                                                               
-  Unless required by applicable law or agreed to in writing,   
-  software distributed under the License is distributed on an  
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       
-  KIND, either express or implied.  See the License for the    
-  specific language governing permissions and limitations      
-  under the License.                                           
- -->
-<mailserver>
-    <!-- CHECKME! -->
-    <!-- This is the postmaster email address for this mail server. -->
-    <!-- Set this to the appropriate email address for error reports -->
-    <!-- If this is set to a non-local email address, the mail server -->
-    <!-- will still function, but will generate a warning on startup. -->
-    <postmaster>Postmaster@localhost</postmaster>
-    
-    <!-- Set to true to support virtualHosting. If virtualHosting support is enabled the server will accept thread every user independ on -->
-    <!-- domain level. -->
-    <enableVirtualHosting> false </enableVirtualHosting>     
-      
-    <!-- Set the default domain which will be used if an email is send to a recipient without a domain part -->
-    <!-- If not defaultdomain is set the first domain of the DomainList get used -->
-    <defaultDomain> localhost </defaultDomain>
-      
-    <!-- This is the name used by the server to identify itself in the RemoteManager -->
-    <!-- protocol.  If autodetect is TRUE, the server will discover its -->
-    <!-- own host name and use that in the protocol.  If discovery fails, -->
-    <!-- the value of 'localhost' is used.  If autodetect is FALSE, James -->
-    <!-- will use the specified value. -->
-    <!-- Set the default helloName which is used in all services if not overridden in the specific service-->
-    <helloName autodetect="true">myMailServer</helloName>
-</mailserver>
\ No newline at end of file
Index: container-spring/src/main/config/examples/usersrepository.xml
===================================================================
--- container-spring/src/main/config/examples/usersrepository.xml	(revision 1035153)
+++ container-spring/src/main/config/examples/usersrepository.xml	(working copy)
@@ -42,6 +42,7 @@
      -->
     <repository name="LocalUsers" class="org.apache.james.user.jpa.JPAUsersRepository">
         <algorithm>MD5</algorithm>
+        <enableVirtualHosting>false</enableVirtualHosting>     
     </repository>
 
 
@@ -57,6 +58,7 @@
         <ignoreCase>true</ignoreCase>
         <enableAliases>true</enableAliases>
         <enableForwarding>true</enableForwarding>
+        <enableVirtualHosting>false</enableVirtualHosting>     
     </repository>
     -->
 
@@ -74,6 +76,7 @@
         <ignoreCase>true</ignoreCase>
         <enableAliases>true</enableAliases>
         <enableForwarding>true</enableForwarding>
+        <enableVirtualHosting>false</enableVirtualHosting>     
     </repository>
     -->
         
Index: container-spring/src/main/config/james/domainlist.xml
===================================================================
--- container-spring/src/main/config/james/domainlist.xml	(revision 1048949)
+++ container-spring/src/main/config/james/domainlist.xml	(working copy)
@@ -27,5 +27,6 @@
     </domainnames>
     <autodetect>true</autodetect>
     <autodetectIP>true</autodetectIP>
+    <defaultDomain>localhost</defaultDomain>
   </domainlist>
 </domainlists>
Index: container-spring/src/main/config/james/mailetcontainer.xml
===================================================================
--- container-spring/src/main/config/james/mailetcontainer.xml	(revision 1048949)
+++ container-spring/src/main/config/james/mailetcontainer.xml	(working copy)
@@ -21,7 +21,8 @@
 <!-- See http://james.apache.org/server/3/config.html for usage -->
 
 <mailetcontainer>
-
+    <postmaster>Postmaster@localhost</postmaster>
+    
     <threads> 20 </threads>
 
     <mailetpackages>
Index: container-spring/src/main/config/james/mailserver.xml
===================================================================
--- container-spring/src/main/config/james/mailserver.xml	(revision 1048949)
+++ container-spring/src/main/config/james/mailserver.xml	(working copy)
@@ -1,28 +0,0 @@
-<?xml version="1.0"?>
-<!--
-  Licensed to the Apache Software Foundation (ASF) under one   
-  or more contributor license agreements.  See the NOTICE file 
-  distributed with this work for additional information        
-  regarding copyright ownership.  The ASF licenses this file   
-  to you under the Apache License, Version 2.0 (the            
-  "License"); you may not use this file except in compliance   
-  with the License.  You may obtain a copy of the License at   
-                                                               
-    http://www.apache.org/licenses/LICENSE-2.0                 
-                                                               
-  Unless required by applicable law or agreed to in writing,   
-  software distributed under the License is distributed on an  
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       
-  KIND, either express or implied.  See the License for the    
-  specific language governing permissions and limitations      
-  under the License.                                           
- -->
-
-<!-- See http://james.apache.org/server/3/config.html for usage -->
-
-<mailserver>
-  <postmaster>Postmaster@localhost</postmaster>
-  <enableVirtualHosting> false </enableVirtualHosting>     
-  <defaultDomain> localhost </defaultDomain>
-  <helloName autodetect="true">myMailServer</helloName>
-</mailserver>
Index: container-spring/src/main/config/james/usersrepository.xml
===================================================================
--- container-spring/src/main/config/james/usersrepository.xml	(revision 1048949)
+++ container-spring/src/main/config/james/usersrepository.xml	(working copy)
@@ -22,6 +22,7 @@
 
 <usersrepository>
   <repository name="LocalUsers" class="org.apache.james.user.jpa.JPAUsersRepository">
-      <algorithm>MD5</algorithm>
+    <enableVirtualHosting>false</enableVirtualHosting>     
+    <algorithm>MD5</algorithm>
   </repository>
 </usersrepository>
Index: container-spring/src/main/config/james/context/james-mailbox-maildir-context.xml
===================================================================
--- container-spring/src/main/config/james/context/james-mailbox-maildir-context.xml	(revision 1048949)
+++ container-spring/src/main/config/james/context/james-mailbox-maildir-context.xml	(working copy)
@@ -41,7 +41,7 @@
     </bean>
     <bean id="maildirStore" name="maildir-uidProvider" class="org.apache.james.adapter.mailbox.maildir.MaildirStoreUtil" factory-method="create">
         <constructor-arg index="0" ref="filesystem"/>
-        <constructor-arg index="1" ref="mailserver"/>
+        <constructor-arg index="1" ref="localusersrepository"/>
         <constructor-arg index="2" value="file://var/store/maildir/"/>
     </bean>
 
Index: container-spring/src/main/config/james/context/james-server-context.xml
===================================================================
--- container-spring/src/main/config/james/context/james-server-context.xml	(revision 1048949)
+++ container-spring/src/main/config/james/context/james-server-context.xml	(working copy)
@@ -60,6 +60,7 @@
                 <entry key="spoolmanager" value="mailetcontainer"/>
                 <entry key="mailetloader" value="mailetcontainer"/>
                 <entry key="matcherloader" value="mailetcontainer"/>
+                <entry key="mailetcontext" value="mailetcontainer"/>
                 <entry key="usersstore" value="usersrepository"/>
              </map>
         </property>
@@ -147,9 +148,8 @@
     </camel:camelContext>
 
     <!-- 
-      Mail Server / Queue / Spool / Mailet / Matcher
+      Queue / Spool / Mailet / Matcher
      -->
-    <bean id="mailserver" class="org.apache.james.JamesMailServer"/>
     <bean id="mailQueueFactory" class="org.apache.james.queue.activemq.ActiveMQMailQueueFactory" depends-on="broker"/>
     <bean id="mailProcessor" name="processorRoute" class="org.apache.james.mailetcontainer.camel.CamelMailProcessorList"/>
     <bean id="spoolmanager" class="org.apache.james.transport.JamesSpoolManager"/>
Index: core-api/src/main/java/org/apache/james/services/MailServer.java
===================================================================
--- core-api/src/main/java/org/apache/james/services/MailServer.java	(revision 1033370)
+++ core-api/src/main/java/org/apache/james/services/MailServer.java	(working copy)
@@ -1,70 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-
-
-package org.apache.james.services;
-
-
-import org.apache.mailet.MailAddress;
-
-/**
- * The interface for Phoenix blocks to the James MailServer
- *
- *
- * @version This is $Revision$
- */
-public interface MailServer{
-  
-    /**
-     * Generate a new identifier/name for a mail being processed by this server.
-     *
-     * @return the new identifier
-     */
-    String getId();
-    
-    /**
-     * Return true if virtualHosting support is enabled, otherwise false
-     * 
-     * @return true or false
-     */
-    boolean supportVirtualHosting();
-    
-    /**
-     * Return the default domain which will get used to deliver mail to if only the localpart
-     * was given on rcpt to.
-     * 
-     * @return the defaultdomain
-     */
-    String getDefaultDomain();
-    
-    /**
-     * Return the helloName which should use for all services by default
-     * 
-     * @return the helloName
-     */
-    String getHelloName();
-    
-    /**
-     * Return the {@link MailAddress} of the postmaster
-     * 
-     * @return postmaster
-     */
-    public MailAddress getPostmaster();
-}
Index: core-function/src/main/java/org/apache/james/JamesMailServer.java
===================================================================
--- core-function/src/main/java/org/apache/james/JamesMailServer.java	(revision 1035153)
+++ core-function/src/main/java/org/apache/james/JamesMailServer.java	(working copy)
@@ -1,249 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-
-
-package org.apache.james;
-
-import java.net.UnknownHostException;
-import java.util.Locale;
-import java.util.UUID;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-import javax.mail.internet.ParseException;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.commons.logging.Log;
-import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.domainlist.api.DomainList;
-import org.apache.james.lifecycle.Configurable;
-import org.apache.james.lifecycle.LogEnabled;
-import org.apache.james.services.MailServer;
-import org.apache.mailet.MailAddress;
-
-/**
- * 
- */
-public class JamesMailServer
-    implements MailServer, LogEnabled, Configurable {
-
-    /**
-     * The software name and version
-     */
-    private final static String SOFTWARE_NAME_VERSION = Constants.SOFTWARE_NAME + " " + Constants.SOFTWARE_VERSION;
-
-    /**
-     * The top level configuration object for this server.
-     */
-    private HierarchicalConfiguration conf = null;
-
-    private DomainList domains;
-    
-    private boolean virtualHosting = false;
-    
-    private String defaultDomain = null;
-    
-    private String helloName = null;
-
-    private Log logger;
-
-    private DNSService dns;    
-
-    private MailAddress postmaster;
-
-    @Resource(name="domainlist")
-    public void setDomainList(DomainList domains) {
-        this.domains = domains;
-    }
-    
-    @Resource(name="dnsservice")
-    public void setDNSService(DNSService dns) {
-        this.dns = dns;
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.lifecycle.LogEnabled#setLog(org.apache.commons.logging.Log)
-     */
-    public final void setLog(Log logger) {
-        this.logger = logger;
-    }
-    
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.HierarchicalConfiguration)
-     */
-    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
-        this.conf = (HierarchicalConfiguration)config;
-    }
-    
-    
-	@PostConstruct
-    public void init() throws Exception {
-
-        logger.info("JAMES init...");                
-        
-        if (conf.getKeys("usernames").hasNext()) {
-        	throw new ConfigurationException("<usernames> parameter in James block was removed. Please configure this data in UsersRepository block");
-        }
-        
-        if (conf.getKeys("servernames").hasNext()) {
-        	throw new ConfigurationException("<servernames> parameter in mailserver block was removed. Please configure this data in domainlist block");
-        }
-
-        initializeServernames();
-        
-        virtualHosting = conf.getBoolean("enableVirtualHosting", false);
-
-        logger.info("VirtualHosting supported: " + virtualHosting);
-        
-        defaultDomain = conf.getString("defaultDomain",null);
-        if (defaultDomain == null && virtualHosting) {
-            throw new ConfigurationException("Please configure a defaultDomain if using VirtualHosting");
-        }
-        
-        logger.info("Defaultdomain: " + defaultDomain);
-        
-        if (conf.getKeys("helloName").hasNext()) {
-            HierarchicalConfiguration helloNameConfig = conf.configurationAt("helloName");
-            boolean autodetect = helloNameConfig.getBoolean("[@autodetect]", true);
-            if (autodetect) {
-                try {
-                    helloName = dns.getHostName(dns.getLocalHost());
-                } catch (UnknownHostException e) {
-                    helloName = "localhost";
-                }
-            } else {
-                // Should we use the defaultdomain here ?
-                helloName = conf.getString("helloName",defaultDomain);
-            }
-        }
-
-
-        initPostmaster();
-        System.out.println(SOFTWARE_NAME_VERSION);
-    }
-
-
-    private void initializeServernames() throws ConfigurationException, ParseException {
-        String defaultDomain = getDefaultDomain();
-        if (domains.containsDomain(defaultDomain) == false) {
-            logger.warn("Configured defaultDomain not exist in DomainList, please add it ASAP!");
-            
-        }
-       
-    }
-
- 
-
-    /**
-     * The Id generated by this method use a combination of {@link System#currentTimeMillis()} and {@link UUID#randomUUID()}
-     * So it should be safe to have an unique ID even when used in distributed fashion.
-     * 
-     * @see org.apache.james.services.MailServer#getId()
-     */
-    public String getId() {
-        StringBuilder idBuffer = new StringBuilder()
-                    .append("Mail")
-                    .append(System.currentTimeMillis())
-                    .append("-")
-                    .append(UUID.randomUUID());
-        return idBuffer.toString();
-    }
-
-    /**
-     * @see org.apache.james.services.MailServer#supportVirtualHosting()
-     */
-    public boolean supportVirtualHosting() {
-        return virtualHosting;
-    }
-
-    /**
-     * @see org.apache.james.services.MailServer#getDefaultDomain()
-     */
-    public String getDefaultDomain() {
-        if (defaultDomain == null) {
-            String[] domainList = domains.getDomains();
-            if (domainList == null || domainList.length < 1) {
-                return conf.getString("defaultDomain", "localhost");
-            } else {
-                return domainList[0];
-            }  
-        } else {
-            return defaultDomain;
-        }
-    }
-
-    /**
-     * @see org.apache.james.services.MailServer#getHelloName()
-     */
-    public String getHelloName() {
-        if (helloName != null) {
-            return helloName;
-        } else {
-            return getDefaultDomain();
-        }
-    }
-    
-    
-    private void initPostmaster() throws Exception {
-        // Get postmaster
-        String postMasterAddress = conf.getString("postmaster", "postmaster").toLowerCase(Locale.US);
-        // if there is no @domain part, then add the first one from the
-        // list of supported domains that isn't localhost. If that
-        // doesn't work, use the hostname, even if it is localhost.
-        if (postMasterAddress.indexOf('@') < 0) {
-            String domainName = null; // the domain to use
-            // loop through candidate domains until we find one or exhaust the
-            // list
-            String[] doms = domains.getDomains();
-            if (doms != null) {
-                for (int i = 0; i < doms.length; i++) {
-                    String serverName = doms[i].toLowerCase(Locale.US);
-                    if (!("localhost".equals(serverName))) {
-                        domainName = serverName; // ok, not localhost, so use it
-                        continue;
-                    }
-                }
-            
-            }
-            // if we found a suitable domain, use it. Otherwise fallback to the
-            // host name.
-            postMasterAddress = postMasterAddress + "@" + (domainName != null ? domainName : getDefaultDomain());
-        }
-        this.postmaster = new MailAddress(postMasterAddress);
-
-        if (!domains.containsDomain(postmaster.getDomain())) {
-            StringBuffer warnBuffer = new StringBuffer(320).append("The specified postmaster address ( ").append(postmaster).append(
-                    " ) is not a local address.  This is not necessarily a problem, but it does mean that emails addressed to the postmaster will be routed to another server.  For some configurations this may cause problems.");
-            logger.warn(warnBuffer.toString());
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.james.services.MailServer#getPostmaster()
-     */
-    public MailAddress getPostmaster() {
-        return postmaster;
-    }
-
-}
Index: core-library/src/main/java/org/apache/james/core/MailImpl.java
===================================================================
--- core-library/src/main/java/org/apache/james/core/MailImpl.java	(revision 1033370)
+++ core-library/src/main/java/org/apache/james/core/MailImpl.java	(working copy)
@@ -44,6 +44,7 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.UUID;
 
 /**
  * <P>Wraps a MimeMessage adding routing information (from SMTP) and some simple
@@ -634,5 +635,20 @@
                                  .append(random.nextInt(1048576));
         return nameBuffer.toString();
     }
+    
+    /**
+     * Generate a new identifier/name for a mail being processed by this server.
+     *
+     * @return the new identifier
+     */
+    public static String getId() {
+        StringBuilder idBuffer = new StringBuilder()
+                    .append("Mail")
+                    .append(System.currentTimeMillis())
+                    .append("-")
+                    .append(UUID.randomUUID());
+        return idBuffer.toString();
+    }
 
+
 }
Index: core-library/src/test/java/org/apache/james/services/MailServerTestAllImplementations.java
===================================================================
--- core-library/src/test/java/org/apache/james/services/MailServerTestAllImplementations.java	(revision 1033370)
+++ core-library/src/test/java/org/apache/james/services/MailServerTestAllImplementations.java	(working copy)
@@ -1,61 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-
-
-package org.apache.james.services;
-
-import junit.framework.TestCase;
-
-/**
- * tests all implementations for interface MailServer
- */
-abstract public class MailServerTestAllImplementations extends TestCase {
-    
-    protected static final String EXISTING_USER_NAME = "testExistingUserName";
-
-    abstract public MailServer createMailServer() throws Exception;
-    abstract public boolean allowsPasswordlessUser();
-
-    /**
-     * while addUser() is part of MailServer interface, a user cannot be tested for afterwards
-     * at the same time, James allows to do exactly this via isLocalUser(), other implementations
-     * might vary. 
-     */
-    abstract public boolean canTestUserExists();
-    abstract public boolean isUserExisting(MailServer mailServerImpl, String username);
-    
-    public void testId() throws Exception {
-        MailServer mailServer = createMailServer();
-        
-        String id = mailServer.getId();
-        assertNotNull("mail id not null", id);
-        assertFalse("mail id not empty", "".equals(id));
-    }
-    
-    public void testIdIncrement() throws Exception {
-        MailServer mailServer = createMailServer();
-        
-        String id1 = mailServer.getId();
-        String id2 = mailServer.getId();
-        assertFalse("next id is different", id1.equals(id2));
-    }
-    
-  
-}
Index: core-library/src/test/java/org/apache/james/services/MockMailServer.java
===================================================================
--- core-library/src/test/java/org/apache/james/services/MockMailServer.java	(revision 1033370)
+++ core-library/src/test/java/org/apache/james/services/MockMailServer.java	(working copy)
@@ -1,64 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.services;
-
-
-import javax.mail.internet.AddressException;
-
-import org.apache.mailet.MailAddress;
-import org.apache.mailet.base.test.MailUtil;
-
-public class MockMailServer implements MailServer {
-
-    
-    private boolean virtualHosting;
-
-
-    public synchronized String getId() {
-        return MailUtil.newId();
-    }
-
-    
-    public void setVirtualHosting(boolean virtualHosting) {
-        this.virtualHosting = virtualHosting;
-    }
-
-    public boolean supportVirtualHosting() {
-        return virtualHosting;
-    }
-
-    public String getDefaultDomain() {
-        return "localhost";
-    }
-
-    public String getHelloName() {
-        return "localhost";
-    }
-
-    public MailAddress getPostmaster() {
-        try {
-            return new MailAddress("postmaster", "localhost");
-        } catch (AddressException e) {
-            return null;
-        }
-    }
-}
-
-
Index: domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainList.java
===================================================================
--- domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainList.java	(revision 1033370)
+++ domainlist-api/src/main/java/org/apache/james/domainlist/api/DomainList.java	(working copy)
@@ -59,4 +59,14 @@
      */
     public boolean removeDomain(String domain);
     
+    
+    
+    /**
+     * Return the default domain which will get used to deliver mail to if only the localpart
+     * was given on rcpt to.
+     * 
+     * @return the defaultdomain
+     */
+    public String getDefaultDomain();
+    
 }
Index: domainlist-api/src/test/java/org/apache/james/domainlist/api/SimpleDomainList.java
===================================================================
--- domainlist-api/src/test/java/org/apache/james/domainlist/api/SimpleDomainList.java	(revision 1033370)
+++ domainlist-api/src/test/java/org/apache/james/domainlist/api/SimpleDomainList.java	(working copy)
@@ -46,4 +46,8 @@
     public boolean removeDomain(String domain) {
         return domains.remove(domain);
     }
+
+    public String getDefaultDomain() {
+        return "localhost";
+    }
 }
\ No newline at end of file
Index: domainlist-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java
===================================================================
--- domainlist-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java	(revision 1048964)
+++ domainlist-library/src/main/java/org/apache/james/domainlist/lib/AbstractDomainList.java	(working copy)
@@ -30,19 +30,23 @@
 
 import javax.annotation.Resource;
 
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.lifecycle.Configurable;
 import org.apache.james.lifecycle.LogEnabled;
 
 /**
  * All implementations of the DomainList interface should extends this abstract class
  */
-public abstract class AbstractDomainList implements  DomainList, LogEnabled {
+public abstract class AbstractDomainList implements  DomainList, LogEnabled, Configurable {
     private DNSService dns;
     private boolean autoDetect = true;
     private boolean autoDetectIP = true;
     private Log logger;
+    private String defaultDomain;
     
     @Resource(name="dnsservice")
     public void setDNSService(DNSService dns) {
@@ -60,6 +64,23 @@
 
     
     
+    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+        defaultDomain = config.getString("defaultDomain","localhost");
+
+        setAutoDetect(config.getBoolean("autodetect", true));    
+        setAutoDetectIP(config.getBoolean("autodetectIP", true));            
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.domainlist.api.DomainList#getDefaultDomain()
+     */
+    public String getDefaultDomain() {
+        return defaultDomain;
+    }
+
+
     /*
      * (non-Javadoc)
      * @see org.apache.james.api.domainlist.DomainList#getDomains()
Index: domainlist-library/src/main/java/org/apache/james/domainlist/lib/DomainListManagement.java
===================================================================
--- domainlist-library/src/main/java/org/apache/james/domainlist/lib/DomainListManagement.java	(revision 1033370)
+++ domainlist-library/src/main/java/org/apache/james/domainlist/lib/DomainListManagement.java	(working copy)
@@ -54,4 +54,8 @@
         return domainList.removeDomain(domain);
     }
 
+    public String getDefaultDomain() {
+        return domainList.getDefaultDomain();
+    }
+
 }
Index: domainlist-library/src/main/java/org/apache/james/domainlist/lib/JamesDomainList.java
===================================================================
--- domainlist-library/src/main/java/org/apache/james/domainlist/lib/JamesDomainList.java	(revision 1033370)
+++ domainlist-library/src/main/java/org/apache/james/domainlist/lib/JamesDomainList.java	(working copy)
@@ -133,4 +133,12 @@
         this.config = config;
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.domainlist.api.DomainList#getDefaultDomain()
+     */
+    public String getDefaultDomain() {
+        return domainList.getDefaultDomain();
+    }
+
 }
Index: domainlist-xml/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java
===================================================================
--- domainlist-xml/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java	(revision 1048976)
+++ domainlist-xml/src/main/java/org/apache/james/domainlist/xml/XMLDomainList.java	(working copy)
@@ -46,13 +46,12 @@
      */
     @SuppressWarnings("unchecked")
     public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+        super.configure(config);
         List<String> serverNameConfs = config.getList( "domainnames.domainname" );
         for ( int i = 0; i < serverNameConfs.size(); i++ ) {
             addDomainInternal( serverNameConfs.get(i));
         }
         
-        setAutoDetect(config.getBoolean("autodetect", true));    
-        setAutoDetectIP(config.getBoolean("autodetectIP", true));    
     }
    
    
Index: fetchmail/src/main/java/org/apache/james/fetchmail/FetchMail.java
===================================================================
--- fetchmail/src/main/java/org/apache/james/fetchmail/FetchMail.java	(revision 1035599)
+++ fetchmail/src/main/java/org/apache/james/fetchmail/FetchMail.java	(working copy)
@@ -42,7 +42,6 @@
 import org.apache.james.lifecycle.Configurable;
 import org.apache.james.lifecycle.LogEnabled;
 import org.apache.james.queue.api.MailQueue;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 
 /**
@@ -388,10 +387,6 @@
      */
     private Map<DynamicAccountKey, DynamicAccount> fieldDynamicAccounts;        
     
-   /**
-     * The MailServer service
-     */
-    private MailServer fieldServer;
     
    /**
      * The Local Users repository
@@ -435,7 +430,6 @@
             new ParsedConfiguration(
                 configuration,
                 logger,
-                getServer(),
                 getLocalUsers(),
                 getDNSService());
         setParsedConfiguration(parsedConfiguration);
@@ -612,14 +606,6 @@
         fieldFetching = fetching;
     }
 
-    /**
-     * Returns the server.
-     * @return MailServer
-     */
-    protected MailServer getServer()
-    {
-        return fieldServer;
-    }
 
     /**
      * Returns the configuration.
@@ -664,11 +650,6 @@
     public void setDNSService(DNSService dns) {
         this.dnsServer = dns;
     }
-
-
-    public void setMailServer(MailServer mailserver) {
-        this.fieldServer = mailserver;
-    }
    
     public void setUsersRepository(UsersRepository urepos) {
         this.fieldLocalUsers = urepos;
Index: fetchmail/src/main/java/org/apache/james/fetchmail/FetchScheduler.java
===================================================================
--- fetchmail/src/main/java/org/apache/james/fetchmail/FetchScheduler.java	(revision 1033370)
+++ fetchmail/src/main/java/org/apache/james/fetchmail/FetchScheduler.java	(working copy)
@@ -40,7 +40,6 @@
 import org.apache.james.lifecycle.LogEnabled;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueueFactory;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 
 /**
@@ -73,8 +72,6 @@
     private DNSService dns;
 
 
-    private MailServer mailserver;
-
 
     private UsersRepository urepos;
     
@@ -102,11 +99,6 @@
         this.dns = dns;
     }
 
-
-    @Resource(name="mailserver")
-    public void setMailServer(MailServer mailserver) {
-        this.mailserver = mailserver;
-    }
    
     @Resource(name="localusersrepository")
     public void setUsersRepository(UsersRepository urepos) {
@@ -142,7 +134,6 @@
                     
                 fetcher.setLog(logger);
                 fetcher.setDNSService(dns);
-                fetcher.setMailServer(mailserver);
                 fetcher.setUsersRepository(urepos);
                 fetcher.setMailQueue(queue);
                 fetcher.configure(fetchConf);
Index: fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java
===================================================================
--- fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java	(revision 1035583)
+++ fetchmail/src/main/java/org/apache/james/fetchmail/MessageProcessor.java	(working copy)
@@ -623,7 +623,7 @@
         Collection<MailAddress> recipients = new ArrayList<MailAddress>(1);
         recipients.add(recipient);
         MailImpl mail =
-            new MailImpl(getServer().getId(), getSender(), recipients, message);
+            new MailImpl(MailImpl.getId(), getSender(), recipients, message);
         
 
         try {
@@ -896,7 +896,7 @@
         if (isLocalServer(recipient)) {
             // check if we use virtualhosting or not and use the right part of the recipient in respect of this
             // See JAMES-1135
-            if (getServer().supportVirtualHosting()) {
+            if (getConfiguration().getLocalUsers().supportVirtualHosting()) {
                 return getLocalUsers().contains(recipient.toString());
             } else {
                 return getLocalUsers().contains(recipient.getLocalPart());
Index: fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java
===================================================================
--- fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java	(revision 1033370)
+++ fetchmail/src/main/java/org/apache/james/fetchmail/ParsedConfiguration.java	(working copy)
@@ -34,7 +34,6 @@
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.queue.api.MailQueue;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.MailAddress;
 
@@ -202,11 +201,6 @@
      */
     private boolean fieldRecurse = false;
     
-
-    /**
-     * The MailServer service
-     */
-    private MailServer fieldServer;    
     
 
     /**
@@ -328,16 +322,14 @@
      * Constructor for ParsedConfiguration.
      * @param configuration
      * @param logger
-     * @param server
      * @param localUsers
      * @param dnsServer
      * @throws ConfigurationException
      */
-    public ParsedConfiguration(HierarchicalConfiguration configuration, Log logger, MailServer server, UsersRepository localUsers,DNSService dnsServer) throws ConfigurationException
+    public ParsedConfiguration(HierarchicalConfiguration configuration, Log logger, UsersRepository localUsers,DNSService dnsServer) throws ConfigurationException
     {
         this();
         setLogger(logger);
-        setServer(server);
         setLocalUsers(localUsers);   
         setDNSServer(dnsServer);
         configure(configuration);
@@ -517,15 +509,6 @@
     }
 
     /**
-     * Returns the server.
-     * @return MailServer
-     */
-    public MailServer getServer()
-    {
-        return fieldServer;
-    }
-
-    /**
      * Sets the fetchAll.
      * @param fetchAll The fetchAll to set
      */
@@ -580,15 +563,6 @@
     }
 
     /**
-     * Sets the server.
-     * @param server The server to set
-     */
-    protected void setServer(MailServer server)
-    {
-        fieldServer = server;
-    }
-
-    /**
      * Returns the logger.
      * @return Logger
      */
Index: fetchmail/src/main/java/org/apache/james/fetchmail/ProcessorAbstract.java
===================================================================
--- fetchmail/src/main/java/org/apache/james/fetchmail/ProcessorAbstract.java	(revision 1033370)
+++ fetchmail/src/main/java/org/apache/james/fetchmail/ProcessorAbstract.java	(working copy)
@@ -30,7 +30,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.queue.api.MailQueue;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.MailAddress;
 
@@ -187,16 +186,6 @@
         return getConfiguration().getRemoteReceivedHeaderIndex();    
     }
 
-
-    /**
-     * Returns the server.
-     * @return MailServer
-     */
-    protected MailServer getServer()
-    {
-        return getConfiguration().getServer();
-    }
-    
     /**
      * Returns the DNSService
      * @return DNSService
Index: lmtpserver/src/main/java/org/apache/james/lmtpserver/DataLineLMTPMessageHookHandler.java
===================================================================
--- lmtpserver/src/main/java/org/apache/james/lmtpserver/DataLineLMTPMessageHookHandler.java	(revision 1040035)
+++ lmtpserver/src/main/java/org/apache/james/lmtpserver/DataLineLMTPMessageHookHandler.java	(working copy)
@@ -42,8 +42,8 @@
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.DataLineFilter;
 import org.apache.james.protocols.smtp.dsn.DSNStatus;
-import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.SMTPConstants;
+import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 
@@ -53,16 +53,12 @@
  *
  */
 public class DataLineLMTPMessageHookHandler implements DataLineFilter {
-    private MailServer mailServer;
+    private UsersRepository users;
     private MailboxManager mailboxManager;
-    
-   /**
-    * Sets the mail server.
-    * @param mailServer the mailServer to
-    */
-   @Resource(name="mailserver")
-   public final void setMailServer(MailServer mailServer) {
-       this.mailServer = mailServer;
+
+   @Resource(name="localusersrepository")
+   public final void setUsersRepository(UsersRepository users) {
+       this.users = users;
    }
    
    @Resource(name="mailboxmanager")
@@ -85,7 +81,7 @@
                 
                 List recipientCollection = (List) session.getState().get(SMTPSession.RCPT_LIST);
                 MailImpl mail =
-                    new MailImpl(mailServer.getId(),
+                    new MailImpl(MailImpl.getId(),
                                  (MailAddress) session.getState().get(SMTPSession.SENDER),
                                  recipientCollection);
                 
@@ -151,7 +147,7 @@
         while (recipients.hasNext()) {
             MailAddress recipient = recipients.next();
             String username;
-            if (mailServer.supportVirtualHosting()) {
+            if (users.supportVirtualHosting()) {
                 username = recipient.toString();
             } else {
                 username = recipient.getLocalPart();
Index: lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/LMTPServer.java
===================================================================
--- lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/LMTPServer.java	(revision 1040035)
+++ lmtpserver/src/main/java/org/apache/james/lmtpserver/netty/LMTPServer.java	(working copy)
@@ -26,7 +26,6 @@
 import org.apache.james.protocols.api.ProtocolHandlerChain;
 import org.apache.james.protocols.impl.AbstractSSLAwareChannelPipelineFactory;
 import org.apache.james.protocols.smtp.SMTPConfiguration;
-import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.netty.SMTPChannelUpstreamHandler;
 import org.apache.james.smtpserver.netty.SMTPResponseEncoder;
 import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
@@ -44,18 +43,12 @@
      * value, 0, means no limit.
      */
     private long maxMessageSize = 0;
-    private MailServer mailServer;
     private ProtocolHandlerChain handlerChain;
     private LMTPConfiguration lmtpConfig = new LMTPConfiguration();
     private String lmtpGreeting;
     private final ConnectionCountHandler countHandler = new ConnectionCountHandler();
     
 
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
-    
 
     public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
         this.handlerChain = handlerChain;
@@ -110,11 +103,7 @@
          * @see org.apache.james.protocols.smtp.SMTPConfiguration#getHelloName()
          */
         public String getHelloName() {
-            if (LMTPServer.this.getHelloName() == null) {
-                return LMTPServer.this.mailServer.getHelloName();
-            } else {
-                return LMTPServer.this.getHelloName();
-            }
+            return LMTPServer.this.getHelloName();
         }
 
         /**
Index: mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/maildir/MaildirStoreUtil.java
===================================================================
--- mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/maildir/MaildirStoreUtil.java	(revision 1045022)
+++ mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/maildir/MaildirStoreUtil.java	(working copy)
@@ -22,7 +22,7 @@
 
 import org.apache.james.mailbox.maildir.MaildirStore;
 import org.apache.james.services.FileSystem;
-import org.apache.james.services.MailServer;
+import org.apache.james.user.api.UsersRepository;
 
 /**
  * Utility to instance a {@link MaildirStore} object
@@ -40,10 +40,10 @@
      * @return store
      * @throws FileNotFoundException
      */
-    public static MaildirStore create(FileSystem fs, MailServer mailServer, String rootURL) throws FileNotFoundException {
+    public static MaildirStore create(FileSystem fs, UsersRepository usersRepos, String rootURL) throws FileNotFoundException {
         StringBuffer root = new StringBuffer();
         root.append(fs.getFile(rootURL).getAbsolutePath());
-        if (mailServer.supportVirtualHosting()) {
+        if (usersRepos.supportVirtualHosting()) {
             root.append("/%domain/%user/");
         } else {
             root.append("/%user/");
Index: mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java
===================================================================
--- mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java	(revision 1033370)
+++ mailetcontainer-library/src/main/java/org/apache/james/mailetcontainer/lib/JamesMailetContext.java	(working copy)
@@ -27,25 +27,29 @@
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.Locale;
 import java.util.Vector;
 
 import javax.annotation.Resource;
 import javax.mail.Address;
 import javax.mail.Message;
 import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.ParseException;
 
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.james.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.TemporaryResolutionException;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.lifecycle.Configurable;
 import org.apache.james.lifecycle.LifecycleUtil;
 import org.apache.james.lifecycle.LogEnabled;
 import org.apache.james.mailetcontainer.api.MailProcessor;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.HostAddress;
 import org.apache.mailet.Mail;
@@ -53,9 +57,7 @@
 import org.apache.mailet.MailetContext;
 import org.apache.mailet.base.RFC2822Headers;
 
-public class JamesMailetContext implements MailetContext, LogEnabled {
-
-    private MailServer mailServer;
+public class JamesMailetContext implements MailetContext, LogEnabled, Configurable {
 
     /**
      * A hash table of server attributes These are the MailetContext attributes
@@ -71,10 +73,8 @@
 
     private DomainList domains;
 
-    @Resource(name = "mailserver")
-    public void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
+    private MailAddress postmaster;
+
 
     @Resource(name="mailProcessor")
     public void setMailProcessor(MailProcessor processorList) {
@@ -242,7 +242,7 @@
         }
         try {
             if (name.indexOf("@") == -1) {
-                return isLocalEmail(new MailAddress(name, mailServer.getDefaultDomain()));
+                return isLocalEmail(new MailAddress(name, domains.getDefaultDomain()));
             } else {
                 return isLocalEmail(new MailAddress(name));
             }
@@ -260,7 +260,7 @@
         if (!isLocalServer(mailAddress.getDomain())) {
             return false;
         }
-        if (mailServer.supportVirtualHosting() == false) {
+        if (localusers.supportVirtualHosting() == false) {
             userName = mailAddress.getLocalPart();
         }
         return localusers.contains(userName);
@@ -270,7 +270,7 @@
      * @see org.apache.mailet.MailetContext#getPostmaster()
      */
     public MailAddress getPostmaster() {
-        return mailServer.getPostmaster();
+        return postmaster;
     }
 
     /**
@@ -397,7 +397,7 @@
      */
     @SuppressWarnings("unchecked")
 	public void sendMail(MailAddress sender, Collection recipients, MimeMessage message, String state) throws MessagingException {
-        MailImpl mail = new MailImpl(mailServer.getId(), sender, recipients, message);
+        MailImpl mail = new MailImpl(MailImpl.getId(), sender, recipients, message);
         try {
             mail.setState(state);
             sendMail(mail);
@@ -431,4 +431,47 @@
     public void setLog(Log log) {
         this.log = log;
     }
+
+
+    /*
+     * 
+     */
+    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+        // Get postmaster
+        String postMasterAddress = config.getString("postmaster", "postmaster").toLowerCase(Locale.US);
+        // if there is no @domain part, then add the first one from the
+        // list of supported domains that isn't localhost. If that
+        // doesn't work, use the hostname, even if it is localhost.
+        if (postMasterAddress.indexOf('@') < 0) {
+            String domainName = null; // the domain to use
+            // loop through candidate domains until we find one or exhaust the
+            // list
+            String[] doms = domains.getDomains();
+            if (doms != null) {
+                for (int i = 0; i < doms.length; i++) {
+                    String serverName = doms[i].toLowerCase(Locale.US);
+                    if (!("localhost".equals(serverName))) {
+                        domainName = serverName; // ok, not localhost, so use it
+                        continue;
+                    }
+                }
+            
+            }
+            // if we found a suitable domain, use it. Otherwise fallback to the
+            // host name.
+            postMasterAddress = postMasterAddress + "@" + (domainName != null ? domainName : domains.getDefaultDomain());
+        }
+        try {
+            this.postmaster = new MailAddress(postMasterAddress);
+            if (!domains.containsDomain(postmaster.getDomain())) {
+                StringBuffer warnBuffer = new StringBuffer(320).append("The specified postmaster address ( ").append(postmaster).append(
+                        " ) is not a local address.  This is not necessarily a problem, but it does mean that emails addressed to the postmaster will be routed to another server.  For some configurations this may cause problems.");
+                log.warn(warnBuffer.toString());
+            }    
+        } catch (AddressException e) {
+            throw new ConfigurationException("Postmaster address " + postMasterAddress + "is invalid",e);
+        }
+
+    
+    }
 }
Index: mailets/pom.xml
===================================================================
--- mailets/pom.xml	(revision 1045022)
+++ mailets/pom.xml	(working copy)
@@ -118,6 +118,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-domainlist-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-mail-api</artifactId>
     </dependency>
     <dependency>
Index: mailets/src/main/java/org/apache/james/transport/mailets/AbstractRedirect.java
===================================================================
--- mailets/src/main/java/org/apache/james/transport/mailets/AbstractRedirect.java	(revision 1033370)
+++ mailets/src/main/java/org/apache/james/transport/mailets/AbstractRedirect.java	(working copy)
@@ -49,7 +49,6 @@
 import org.apache.james.core.MailImpl;
 import org.apache.james.core.MimeMessageUtil;
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.services.MailServer;
 
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.Mail;
@@ -234,15 +233,9 @@
 
     private RFC822DateFormat rfc822DateFormat = new RFC822DateFormat();
 
-    protected MailServer mailServer;
-
     protected DNSService dns;
 
     
-    @Resource(name="mailserver")
-    public void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
     
 
     @Resource(name="dnsservice")
Index: mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java
===================================================================
--- mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java	(revision 1033370)
+++ mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTable.java	(working copy)
@@ -36,7 +36,7 @@
 
 import org.apache.james.core.MailImpl;
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.services.MailServer;
+import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.vut.lib.VirtualUserTableUtil;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
@@ -54,19 +54,21 @@
 public abstract class AbstractVirtualUserTable extends GenericMailet
 {
     static private final String MARKER = "org.apache.james.transport.mailets.AbstractVirtualUserTable.mapped";
-    private MailServer mailServer;
     private DNSService dns;
+    private DomainList domainList;
 
-    @Resource(name="mailserver")
-    public void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
     
     @Resource(name="dnsservice")
     public void setDNSService(DNSService dns) {
         this.dns = dns;
     }
     
+    @Resource(name="domainlist")
+    public void setDomainList(DomainList domainList) {
+        this.domainList = domainList;
+    }
+    
+    
     /**
      * Checks the recipient list of the email for user mappings.  Maps recipients as
      * appropriate, modifying the recipient list of the mail and sends mail to any new
@@ -125,7 +127,7 @@
                         }
 
                         try {
-                            MailAddress target = (targetAddress.indexOf('@') < 0) ? new MailAddress(targetAddress, mailServer.getDefaultDomain())
+                            MailAddress target = (targetAddress.indexOf('@') < 0) ? new MailAddress(targetAddress, domainList.getDefaultDomain())
                                 : new MailAddress(targetAddress);
 
                             //Mark this source address as an address to remove from the recipient list
Index: mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTableMailet.java
===================================================================
--- mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTableMailet.java	(revision 1033370)
+++ mailets/src/main/java/org/apache/james/transport/mailets/AbstractVirtualUserTableMailet.java	(working copy)
@@ -29,7 +29,7 @@
 import javax.mail.MessagingException;
 import javax.mail.internet.MimeMessage;
 
-import org.apache.james.services.MailServer;
+import org.apache.james.domainlist.api.DomainList;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 import org.apache.mailet.base.GenericMailet;
@@ -43,13 +43,14 @@
  */
 public abstract class AbstractVirtualUserTableMailet extends GenericMailet {
     
-    private MailServer mailServer;
+    private DomainList domainList;
 
-    @Resource(name="mailserver")
-    public void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
+    @Resource(name="domainlist")
+    public void setDomainList(DomainList domainList) {
+        this.domainList = domainList;
     }
     
+    
     /*
      * (non-Javadoc)
      * @see org.apache.mailet.base.GenericMailet#service(org.apache.mailet.Mail)
@@ -136,7 +137,7 @@
 
             if (rcpt.indexOf("@") < 0) {
                 // the mapping contains no domain name, use the default domain
-                rcpt = rcpt + "@" + mailServer.getDefaultDomain();
+                rcpt = rcpt + "@" + domainList.getDefaultDomain();
             }
 
             MailAddress nextMap = new MailAddress(rcpt);
Index: mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
===================================================================
--- mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java	(revision 1033370)
+++ mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java	(working copy)
@@ -320,7 +320,7 @@
         // failure reports into DSNs
         nameType = "dns";
         try {
-            String myAddress = mailServer.getHelloName();
+            String myAddress = dns.getHostName(dns.getLocalHost());//mailServer.getHelloName();
             /*
             String myAddress = InetAddress.getLocalHost().getCanonicalHostName();
             */
Index: mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java
===================================================================
--- mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java	(revision 1045022)
+++ mailets/src/main/java/org/apache/james/transport/mailets/LocalDelivery.java	(working copy)
@@ -22,7 +22,6 @@
 package org.apache.james.transport.mailets;
 
 import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersStore;
 import org.apache.mailet.base.GenericMailet;
@@ -60,7 +59,6 @@
 
     private UsersStore usersStore;
 
-    private MailServer mailServer;
 
     private MailboxManager mailboxManager;
 
@@ -77,10 +75,6 @@
         this.usersStore = usersStore;
     }
     
-    @Resource(name="mailserver")
-    public void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
     
 
     @Resource(name="mailboxmanager")
@@ -155,7 +149,7 @@
             }
 
         };
-        sieveMailet.setMailServer(mailServer);
+        sieveMailet.setUsersRepository(usersRepository);
         sieveMailet.setMailboxManager(mailboxManager);
         sieveMailet.init(m);
 
Index: mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
===================================================================
--- mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java	(revision 1045022)
+++ mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java	(working copy)
@@ -23,12 +23,12 @@
 
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.TemporaryResolutionException;
+import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.lifecycle.LifecycleUtil;
 import org.apache.james.queue.api.MailQueue;
 import org.apache.james.queue.api.MailQueueFactory;
 import org.apache.james.queue.api.MailQueue.MailQueueException;
 import org.apache.james.queue.api.MailQueue.MailQueueItem;
-import org.apache.james.services.MailServer;
 import org.apache.james.util.TimeConverter;
 import org.apache.mailet.base.GenericMailet;
 import org.apache.mailet.HostAddress;
@@ -190,7 +190,8 @@
 
     private MailQueue queue;
 
-    private MailServer mailServer;
+    private String heloName;
+
     
     
     @Resource(name="mailQueueFactory")
@@ -203,13 +204,14 @@
         this.dnsServer = dnsService;
     }
     
-    @Resource(name="mailserver")
-    public void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
+    private DomainList domainList;
+
+    @Resource(name="domainlist")
+    public void setDomainList(DomainList domainList) {
+        this.domainList = domainList;
     }
     
     
-    
     /**
      * Initializes all arguments based on configuration values specified in the
      * James configuration file.
@@ -376,6 +378,9 @@
         if (dnsRetry != null && !dnsRetry.equals("")) {
             dnsProblemRetry = Integer.parseInt(dnsRetry); 
         }
+        
+        heloName = getInitParameter("heloName");
+
     }
 
     /**
@@ -649,12 +654,6 @@
          * fix.
          */
         long stop = System.currentTimeMillis() + 60000;
-        while (mailServer.getHelloName() == null
-               && stop > System.currentTimeMillis()) {
-            try {
-                Thread.sleep(1000);
-            } catch (Exception ignored) {} // wait for James to finish initializing
-        }
 
         //Checks the pool and delivers a mail message
         Properties props = new Properties();
@@ -674,16 +673,8 @@
         props.put("mail.smtp.connectiontimeout", connectionTimeout + "");
         props.put("mail.smtp.sendpartial",String.valueOf(sendPartial));
 
-        //Set the hostname we'll use as this server
-        if (mailServer.getHelloName() != null) {
-            props.put("mail.smtp.localhost", mailServer.getHelloName());
-        }
-        else {
-            String defaultDomain = mailServer.getDefaultDomain();
-            if (defaultDomain != null) {
-                props.put("mail.smtp.localhost", defaultDomain);
-            }
-        }
+        props.put("mail.smtp.localhost", getHeloName());
+
 
         if (isBindUsed) {
             // undocumented JavaMail 1.2 feature, smtp transport will use
@@ -1474,7 +1465,7 @@
         PrintWriter out = new PrintWriter(sout, true);
         String machine = "[unknown]";
         try {
-            machine = mailServer.getHelloName();
+            machine = getHeloName();
             
         } catch(Exception e){
             machine = "[address unknown]";
@@ -1618,5 +1609,14 @@
             }
         };
     }
+    
+    protected String getHeloName() {
+        if (heloName == null) {
+            //TODO: Maybe we should better just lookup the hostname via dns
+            return domainList.getDefaultDomain();
+        } else {
+            return heloName;
+        }
+    }
   
 }
Index: mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java
===================================================================
--- mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java	(revision 1045035)
+++ mailets/src/main/java/org/apache/james/transport/mailets/SieveMailet.java	(working copy)
@@ -32,7 +32,7 @@
 import org.apache.james.mailbox.MailboxPath;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
-import org.apache.james.services.MailServer;
+import org.apache.james.user.api.UsersRepository;
 import org.apache.jsieve.mailet.Poster;
 import org.apache.jsieve.mailet.SieveMailboxMailet;
 import org.apache.mailet.Mail;
@@ -44,12 +44,12 @@
  */
 public class SieveMailet extends SieveMailboxMailet implements Poster{
 
-    private MailServer mailServer;
+    private UsersRepository usersRepos;
     private MailboxManager mailboxManager;
 
-    @Resource(name="mailserver")
-    public void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
+    @Resource(name="localusersrepository")
+    public void setUsersRepository(UsersRepository usersRepos) {
+        this.usersRepos = usersRepos;
     }
 
     
@@ -61,7 +61,7 @@
     @Override
     public void init(MailetConfig config) throws MessagingException {
         // ATM Fixed implementation
-        setLocator(new ResourceLocatorImpl(mailServer.supportVirtualHosting()));
+        setLocator(new ResourceLocatorImpl(usersRepos.supportVirtualHosting()));
         setPoster(this);
         super.init(config);
     }
@@ -79,7 +79,7 @@
      * @return username
      */
     protected String getUsername(MailAddress m) {
-        if (mailServer.supportVirtualHosting()) {
+        if (usersRepos.supportVirtualHosting()) {
             return m.toString();
         } else {
             return super.getUsername(m);
@@ -134,7 +134,7 @@
 
                     // check if we should use the full emailaddress as
                     // username
-                    if (mailServer.supportVirtualHosting()) {
+                    if (usersRepos.supportVirtualHosting()) {
                         user = user + "@" + host;
                     }
 
Index: pop3server/src/main/java/org/apache/james/pop3server/netty/POP3Server.java
===================================================================
--- pop3server/src/main/java/org/apache/james/pop3server/netty/POP3Server.java	(revision 1040035)
+++ pop3server/src/main/java/org/apache/james/pop3server/netty/POP3Server.java	(working copy)
@@ -26,7 +26,6 @@
 import org.apache.james.pop3server.POP3HandlerConfigurationData;
 import org.apache.james.protocols.api.ProtocolHandlerChain;
 import org.apache.james.protocols.impl.AbstractSSLAwareChannelPipelineFactory;
-import org.apache.james.services.MailServer;
 import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
 import org.apache.james.socket.netty.ConnectionCountHandler;
 import org.jboss.netty.channel.ChannelPipeline;
@@ -56,17 +55,11 @@
     
     private ProtocolHandlerChain handlerChain;
 
-    private MailServer mailServer;
-
     
     public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
         this.handlerChain = handlerChain;
     }
 
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
     @Override
     protected int getDefaultPort() {
         return 110;
@@ -101,11 +94,7 @@
          * @see org.apache.james.pop3server.POP3HandlerConfigurationData#getHelloName()
          */
         public String getHelloName() {
-            if (POP3Server.this.getHelloName() == null) {
-                return POP3Server.this.mailServer.getHelloName();
-            } else {
-                return POP3Server.this.getHelloName();
-            }
+            return POP3Server.this.getHelloName();
         }
 
         /**
Index: pop3server/src/test/java/org/apache/james/pop3server/AbstractAsyncPOP3ServerTest.java
===================================================================
--- pop3server/src/test/java/org/apache/james/pop3server/AbstractAsyncPOP3ServerTest.java	(revision 1045022)
+++ pop3server/src/test/java/org/apache/james/pop3server/AbstractAsyncPOP3ServerTest.java	(working copy)
@@ -39,7 +39,6 @@
 import org.apache.commons.net.pop3.POP3Reply;
 import org.apache.james.services.MockJSR250Loader;
 import org.apache.james.services.MockFileSystem;
-import org.apache.james.services.MockMailServer;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.MockDNSService;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
@@ -49,7 +48,6 @@
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.MailboxConstants;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.lifecycle.LifecycleUtil;
 import org.apache.james.mailbox.store.Authenticator;
 import org.apache.james.socket.JamesProtocolHandlerChain;
 import org.apache.james.user.lib.MockUsersRepository;
@@ -59,7 +57,6 @@
 public abstract class AbstractAsyncPOP3ServerTest extends TestCase {
 
     private int m_pop3ListenerPort = TestUtil.getNonPrivilegedPort();
-    protected MockMailServer m_mailServer;
     private POP3TestConfiguration m_testConfiguration;
     private MockUsersRepository m_usersRepository = new MockUsersRepository();
     private POP3Client m_pop3Protocol = null;
@@ -101,9 +98,6 @@
     
     protected void setUpServiceManager() throws Exception {
         serviceManager = new MockJSR250Loader();
-
-        m_mailServer = new MockMailServer();
-        serviceManager.put("mailserver", m_mailServer);
         serviceManager.put("localusersrepository",
                 m_usersRepository);
         
@@ -145,7 +139,6 @@
                m_pop3Protocol.disconnect();
            }
         }
-        LifecycleUtil.dispose(m_mailServer);
         
         manager.deleteEverything();
         //manager.deleteAll();
Index: pop3server/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
===================================================================
--- pop3server/src/test/java/org/apache/james/pop3server/POP3ServerTest.java	(revision 1035153)
+++ pop3server/src/test/java/org/apache/james/pop3server/POP3ServerTest.java	(working copy)
@@ -44,7 +44,6 @@
         SimpleLog log = new SimpleLog("Mock");
         log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
         m_pop3Server.setLog(log);
-        m_pop3Server.setMailServer(m_mailServer);        
     }
 
     @Override
Index: remotemanager/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java
===================================================================
--- remotemanager/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java	(revision 1033370)
+++ remotemanager/src/main/java/org/apache/james/remotemanager/core/AddUserCmdHandler.java	(working copy)
@@ -33,7 +33,6 @@
 import org.apache.james.remotemanager.CommandHelp;
 import org.apache.james.remotemanager.RemoteManagerResponse;
 import org.apache.james.remotemanager.RemoteManagerSession;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersStore;
 
@@ -46,7 +45,6 @@
     private CommandHelp help = new CommandHelp("adduser [username] [password]","add a new user");
 
     private UsersStore uStore;
-    private MailServer mailServer;
 
     private DomainList domList;
 
@@ -64,15 +62,7 @@
         this.uStore = uStore;
     }
     
-    /**
-     * Sets the mail server.
-     * @param mailServer the mailServer to set
-     */
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
-    
+
     /**
      * @see org.apache.james.remotemanager.CommandHandler#getHelp()
      */
@@ -113,7 +103,7 @@
             return response;
         } else {
             if((username.indexOf("@") < 0) == false) {
-                if(mailServer.supportVirtualHosting() == false) {
+                if(users.supportVirtualHosting() == false) {
                     response = new RemoteManagerResponse("Virtualhosting not supported");
                     return response;
                 }
Index: remotemanager/src/main/java/org/apache/james/remotemanager/core/CountUsersCmdHandler.java
===================================================================
--- remotemanager/src/main/java/org/apache/james/remotemanager/core/CountUsersCmdHandler.java	(revision 1033370)
+++ remotemanager/src/main/java/org/apache/james/remotemanager/core/CountUsersCmdHandler.java	(working copy)
@@ -57,7 +57,7 @@
             response = new RemoteManagerResponse("Existing accounts " + users.countUsers());
             return response;
         } else {
-            if(mailServer.supportVirtualHosting() == false) {
+            if(users.supportVirtualHosting() == false) {
                 response = new RemoteManagerResponse("Virtualhosting not supported");
                 return response;
            }
Index: remotemanager/src/main/java/org/apache/james/remotemanager/core/ListUsersCmdHandler.java
===================================================================
--- remotemanager/src/main/java/org/apache/james/remotemanager/core/ListUsersCmdHandler.java	(revision 1033370)
+++ remotemanager/src/main/java/org/apache/james/remotemanager/core/ListUsersCmdHandler.java	(working copy)
@@ -32,7 +32,6 @@
 import org.apache.james.remotemanager.CommandHelp;
 import org.apache.james.remotemanager.RemoteManagerResponse;
 import org.apache.james.remotemanager.RemoteManagerSession;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersStore;
 
@@ -42,7 +41,6 @@
     private CommandHelp help = new CommandHelp("listusers","display existing accounts");
 
     protected UsersStore uStore;
-    protected MailServer mailServer;
 
     /**
      * Sets the users store.
@@ -57,13 +55,6 @@
 
     
     /**
-     * Sets the mail server.
-     * @param mailServer the mailServer to set
-     */
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
     
     /**
      * @see org.apache.james.remotemanager.CommandHandler#getHelp()
@@ -88,7 +79,7 @@
             }
             return response;
         } else {
-            if(mailServer.supportVirtualHosting() == false) {
+            if(users.supportVirtualHosting() == false) {
                 response = new RemoteManagerResponse("Virtualhosting not supported");
                 return response;
             }
Index: remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManager.java
===================================================================
--- remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManager.java	(revision 1035153)
+++ remotemanager/src/main/java/org/apache/james/remotemanager/netty/RemoteManager.java	(working copy)
@@ -30,7 +30,6 @@
 import org.apache.james.protocols.api.ProtocolHandlerChain;
 import org.apache.james.protocols.impl.AbstractChannelPipelineFactory;
 import org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData;
-import org.apache.james.services.MailServer;
 import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
 import org.apache.james.socket.netty.ConnectionCountHandler;
 import org.jboss.netty.channel.ChannelPipeline;
@@ -51,17 +50,12 @@
     private RemoteManagerHandlerConfigurationData configData = new RemoteManagerHandlerConfigurationDataImpl();
     private final ConnectionCountHandler countHandler = new ConnectionCountHandler();
     private ProtocolHandlerChain handlerChain;
-    private MailServer mailServer;
 
     public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
         this.handlerChain = handlerChain;
     }
     
 
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
     
     @Override
     protected int getDefaultPort() {
@@ -99,11 +93,8 @@
          * @see org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getHelloName()
          */
         public String getHelloName() {
-            if (getHelloName() == null) {
-                return RemoteManager.this.mailServer.getHelloName();
-            } else {
-                return RemoteManager.this.getHelloName();
-            }
+            return RemoteManager.this.getHelloName();
+
         }
         
         /**
Index: remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java
===================================================================
--- remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java	(revision 1033370)
+++ remotemanager/src/test/java/org/apache/james/remotemanager/AbstractRemoteManagerTest.java	(working copy)
@@ -38,7 +38,6 @@
 import org.apache.commons.net.telnet.TelnetClient;
 import org.apache.james.services.MockJSR250Loader;
 import org.apache.james.services.MockFileSystem;
-import org.apache.james.services.MockMailServer;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.api.MockDNSService;
 import org.apache.james.domainlist.api.DomainList;
@@ -60,7 +59,6 @@
 	private InternetPrintWriter m_writer;
 	private TelnetClient m_telnetClient;
 	private MockUsersRepository m_mockUsersRepository;
-	protected MockMailServer mailServer;
 	private MockJSR250Loader serviceManager;
 	private MockUsersStore usersStore;
 	protected DNSService dnsservice;
@@ -80,10 +78,6 @@
 				m_remoteManagerListenerPort);
 	}
 
-	protected void tearDown() throws Exception {
-	    LifecycleUtil.dispose(mailServer);
-		super.tearDown();
-	}
 
 	protected void finishSetUp(RemoteManagerTestConfiguration testConfiguration)
 			throws Exception {
@@ -175,8 +169,6 @@
 		usersStore = new MockUsersStore(m_mockUsersRepository);
 		serviceManager.put("usersstore", usersStore);
 
-		mailServer = new MockMailServer();
-		serviceManager.put("mailserver", mailServer);
 		
 		filesystem = new MockFileSystem();
 		serviceManager.put("filesystem", filesystem);
Index: remotemanager/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java
===================================================================
--- remotemanager/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java	(revision 1035153)
+++ remotemanager/src/test/java/org/apache/james/remotemanager/RemoteManagerTest.java	(working copy)
@@ -40,7 +40,6 @@
         SimpleLog log = new SimpleLog("Mock");
         log.setLevel(SimpleLog.LOG_LEVEL_DEBUG);
         remotemanager.setLog(log);
-        remotemanager.setMailServer(mailServer);
                
     }
 
Index: smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java
===================================================================
--- smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java	(revision 1045022)
+++ smtpserver/src/main/java/org/apache/james/smtpserver/DataLineJamesMessageHookHandler.java	(working copy)
@@ -52,7 +52,6 @@
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookResultHook;
 import org.apache.james.protocols.smtp.hook.MessageHook;
-import org.apache.james.services.MailServer;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 
@@ -73,27 +72,8 @@
     
     private List<HookResultHook> rHooks;
     
-    private MailServer mailServer;
-
 	private List<MessageHook> mHandlers;
-    
-    /**
-     * Gets the mail server.
-     * @return the mailServer
-     */
-    public final MailServer getMailServer() {
-        return mailServer;
-    }
 
-    /**
-     * Sets the mail server.
-     * @param mailServer the mailServer to set
-     */
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
-    
 
     /*
      * (non-Javadoc)
@@ -113,7 +93,7 @@
                 
                 List recipientCollection = (List) session.getState().get(SMTPSession.RCPT_LIST);
                 MailImpl mail =
-                    new MailImpl(mailServer.getId(),
+                    new MailImpl(MailImpl.getId(),
                                  (MailAddress) session.getState().get(SMTPSession.SENDER),
                                  recipientCollection);
                 
Index: smtpserver/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java
===================================================================
--- smtpserver/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java	(revision 1045022)
+++ smtpserver/src/main/java/org/apache/james/smtpserver/JamesDataCmdHandler.java	(working copy)
@@ -19,15 +19,14 @@
 package org.apache.james.smtpserver;
 
 
-import javax.annotation.Resource;
 import javax.mail.MessagingException;
 
+import org.apache.james.core.MailImpl;
 import org.apache.james.core.MimeMessageInputStreamSource;
 import org.apache.james.protocols.smtp.SMTPResponse;
 import org.apache.james.protocols.smtp.SMTPRetCode;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.DataCmdHandler;
-import org.apache.james.services.MailServer;
 
 
 /**
@@ -35,26 +34,7 @@
  */
 public class JamesDataCmdHandler extends DataCmdHandler {
 
-    
-
-    private MailServer mailServer;
-    
-    /**
-     * Gets the mail server.
-     * @return the mailServer
-     */
-    public final MailServer getMailServer() {
-        return mailServer;
-    }
-
-    /**
-     * Sets the mail server.
-     * @param mailServer the mailServer to set
-     */
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
+  
  
     /**
      * Handler method called upon receipt of a DATA command.
@@ -66,7 +46,7 @@
      */
     protected SMTPResponse doDATA(SMTPSession session, String argument) {
         try {
-            MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(mailServer.getId());
+            MimeMessageInputStreamSource mmiss = new MimeMessageInputStreamSource(MailImpl.getId());
             session.getState().put(SMTPConstants.DATA_MIMEMESSAGE_STREAMSOURCE, mmiss);
         } catch (MessagingException e) {
             session.getLogger().warn("Error creating mimemessagesource for incoming data",e);
Index: smtpserver/src/main/java/org/apache/james/smtpserver/JamesMailCmdHandler.java
===================================================================
--- smtpserver/src/main/java/org/apache/james/smtpserver/JamesMailCmdHandler.java	(revision 1045022)
+++ smtpserver/src/main/java/org/apache/james/smtpserver/JamesMailCmdHandler.java	(working copy)
@@ -20,35 +20,23 @@
 
 import javax.annotation.Resource;
 
+import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.protocols.smtp.core.MailCmdHandler;
-import org.apache.james.services.MailServer;
 
 public class JamesMailCmdHandler extends MailCmdHandler{
 
-    private MailServer mailServer;
-        
-    /**
-     * Gets the mail server.
-     * @return the mailServer
-     */
-    public final MailServer getMailServer() {
-        return mailServer;
-    }
+    private DomainList domainList;
 
-    /**
-     * Sets the mail server.
-     * @param mailServer the mailServer to set
-     */
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
+    @Resource(name="domainlist")
+    public final void setDomainList(DomainList domainList) {
+        this.domainList = domainList;
     }
 
     /**
      * @see org.apache.james.protocols.smtp.core.MailCmdHandler#getDefaultDomain()
      */
     public String getDefaultDomain() {
-        return mailServer.getDefaultDomain();
+        return domainList.getDefaultDomain();
     }
     
     
Index: smtpserver/src/main/java/org/apache/james/smtpserver/JamesRcptCmdHandler.java
===================================================================
--- smtpserver/src/main/java/org/apache/james/smtpserver/JamesRcptCmdHandler.java	(revision 1045022)
+++ smtpserver/src/main/java/org/apache/james/smtpserver/JamesRcptCmdHandler.java	(working copy)
@@ -21,37 +21,22 @@
 
 import javax.annotation.Resource;
 
+import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.protocols.smtp.core.RcptCmdHandler;
-import org.apache.james.services.MailServer;
 
 public class JamesRcptCmdHandler extends RcptCmdHandler{
-	private MailServer mailServer;
 
-	/**
-	 * Gets the mail server.
-	 * 
-	 * @return the mailServer
-	 */
-	public final MailServer getMailServer() {
-		return mailServer;
-	}
+    private DomainList domainList;
 
-	/**
-	 * Sets the mail server.
-	 * 
-	 * @param mailServer
-	 *            the mailServer to set
-	 */
-	@Resource(name = "mailserver")
-	public final void setMailServer(MailServer mailServer) {
-		this.mailServer = mailServer;
-	}
+    @Resource(name="domainlist")
+    public final void setDomainList(DomainList domainList) {
+        this.domainList = domainList;
+    }
 
-	/**
-	 * (non-Javadoc)
-	 * @see org.apache.james.protocols.smtp.core.RcptCmdHandler#getDefaultDomain()
-	 */
-    protected String getDefaultDomain() {
-    	return mailServer.getDefaultDomain();
+    /**
+     * @see org.apache.james.protocols.smtp.core.MailCmdHandler#getDefaultDomain()
+     */
+    public String getDefaultDomain() {
+        return domainList.getDefaultDomain();
     }
 }
Index: smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java
===================================================================
--- smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java	(revision 1045022)
+++ smtpserver/src/main/java/org/apache/james/smtpserver/SenderAuthIdentifyVerificationRcptHook.java	(working copy)
@@ -25,8 +25,8 @@
 import org.apache.james.protocols.smtp.core.AbstractSenderAuthIdentifyVerificationRcptHook;
 import org.apache.james.protocols.smtp.hook.HookResult;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
-import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.netty.SMTPNettySession;
+import org.apache.james.user.api.UsersRepository;
 import org.apache.mailet.MailAddress;
 
 /**
@@ -34,17 +34,12 @@
  */
 public class SenderAuthIdentifyVerificationRcptHook extends AbstractSenderAuthIdentifyVerificationRcptHook {
 
-    private MailServer mailServer;
     private DomainList domains;
-    
+    private UsersRepository users;
 
-    /**
-     * Sets the mail server.
-     * @param mailServer the mailServer to set
-     */
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
+    @Resource(name="localusersrepository")
+    public final void setUsersRepository(UsersRepository users) {
+        this.users = users;
     }
 
 
@@ -74,6 +69,6 @@
 
     @Override
     protected boolean useVirtualHosting() {
-        return mailServer.supportVirtualHosting();
+        return users.supportVirtualHosting();
     }
 }
Index: smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
===================================================================
--- smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java	(revision 1045022)
+++ smtpserver/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java	(working copy)
@@ -29,7 +29,6 @@
 import org.apache.james.lifecycle.Configurable;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.core.fastfail.AbstractValidRcptHandler;
-import org.apache.james.services.MailServer;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.vut.api.VirtualUserTable;
 import org.apache.james.vut.api.VirtualUserTable.ErrorMappingException;
@@ -47,8 +46,6 @@
 
     private boolean useVut = true;
 
-    private MailServer mailServer;
-
     private DomainList domains;
 
 	/**
@@ -87,11 +84,6 @@
     public void setDomainList(DomainList domains) {
         this.domains = domains;
     }
-    
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
 
 	/**
 	 * @see org.apache.james.lifecycle.Configurable#configure(org.apache.commons.configuration.Configuration)
@@ -119,7 +111,7 @@
 	    String username = recipient.toString();
 	    
 	    // check if the server use virtualhosting, if not use only the localpart as username
-	    if (mailServer.supportVirtualHosting() == false) {
+	    if (users.supportVirtualHosting() == false) {
 	        username = recipient.getLocalPart();
 	    }
 	    
Index: smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java
===================================================================
--- smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java	(revision 1045022)
+++ smtpserver/src/main/java/org/apache/james/smtpserver/netty/SMTPServer.java	(working copy)
@@ -27,7 +27,6 @@
 import org.apache.james.protocols.api.ProtocolHandlerChain;
 import org.apache.james.protocols.impl.AbstractSSLAwareChannelPipelineFactory;
 import org.apache.james.protocols.smtp.SMTPConfiguration;
-import org.apache.james.services.MailServer;
 import org.apache.james.socket.netty.AbstractConfigurableAsyncServer;
 import org.apache.james.socket.netty.ConnectionCountHandler;
 import org.apache.james.util.netmatcher.NetMatcher;
@@ -97,18 +96,10 @@
 
     private boolean addressBracketsEnforcement = true;
 
-    private MailServer mailServer;
-
     private boolean verifyIdentity;
     
     private final ConnectionCountHandler countHandler = new ConnectionCountHandler();
-    
-
-    @Resource(name="mailserver")
-    public final void setMailServer(MailServer mailServer) {
-        this.mailServer = mailServer;
-    }
-    
+   
 
     public void setProtocolHandlerChain(ProtocolHandlerChain handlerChain) {
         this.handlerChain = handlerChain;
@@ -217,11 +208,7 @@
          * @see org.apache.james.protocols.smtp.SMTPConfiguration#getHelloName()
          */
         public String getHelloName() {
-            if (SMTPServer.this.getHelloName() == null) {
-                return SMTPServer.this.mailServer.getHelloName();
-            } else {
-                return SMTPServer.this.getHelloName();
-            }
+            return SMTPServer.this.getHelloName();
         }
 
         /**
Index: smtpserver/src/test/java/org/apache/james/smtpserver/AbstractSMTPServerTest.java
===================================================================
--- smtpserver/src/test/java/org/apache/james/smtpserver/AbstractSMTPServerTest.java	(revision 1035153)
+++ smtpserver/src/test/java/org/apache/james/smtpserver/AbstractSMTPServerTest.java	(working copy)
@@ -50,7 +50,6 @@
 import org.apache.james.lifecycle.LifecycleUtil;
 import org.apache.james.mailstore.MockMailStore;
 import org.apache.james.services.MockFileSystem;
-import org.apache.james.services.MockMailServer;
 import org.apache.james.socket.JamesProtocolHandlerChain;
 import org.apache.james.user.lib.MockUsersRepository;
 import org.apache.james.util.TestUtil;
@@ -141,7 +140,6 @@
     }
 
     protected final int m_smtpListenerPort;
-    protected MockMailServer m_mailServer;
     //private SMTPServer m_smtpServer;
     protected SMTPTestConfiguration m_testConfiguration;
     protected MockUsersRepository m_usersRepository = new MockUsersRepository();
@@ -187,7 +185,6 @@
 
 
     protected void tearDown() throws Exception {
-        LifecycleUtil.dispose(m_mailServer);
         queue.clear();
         super.tearDown();
         
@@ -216,8 +213,6 @@
 
     protected void setUpFakeLoader() throws Exception {
         m_serviceManager = new MockJSR250Loader();
-        m_mailServer = new MockMailServer();
-        m_serviceManager.put("mailserver", m_mailServer);
         m_serviceManager.put("localusersrepository", m_usersRepository);
 
         m_dnsServer = new AlterableDNSServer();
Index: smtpserver/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
===================================================================
--- smtpserver/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java	(revision 1035153)
+++ smtpserver/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java	(working copy)
@@ -46,7 +46,6 @@
         m_smtpServer.setProtocolHandlerChain(chain);
         
         m_smtpServer.setLog(log);
-        m_smtpServer.setMailServer(m_mailServer);        
     }
 
     @Override
Index: smtpserver/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java
===================================================================
--- smtpserver/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java	(revision 1033370)
+++ smtpserver/src/test/java/org/apache/james/smtpserver/ValidRcptHandlerTest.java	(working copy)
@@ -30,12 +30,11 @@
 
 import junit.framework.TestCase;
 
-import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.domainlist.api.SimpleDomainList;
 import org.apache.james.protocols.smtp.BaseFakeSMTPSession;
 import org.apache.james.protocols.smtp.SMTPConfiguration;
 import org.apache.james.protocols.smtp.SMTPSession;
 import org.apache.james.protocols.smtp.hook.HookReturnCode;
-import org.apache.james.services.MailServer;
 import org.apache.james.smtpserver.fastfail.ValidRcptHandler;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.lib.MockUsersRepository;
@@ -60,55 +59,13 @@
         handler = new ValidRcptHandler();
         handler.setUsers(users);
         handler.setVirtualUserTable(setUpVirtualUserTable());
-        handler.setMailServer(new MailServer() {
-
-            public String getDefaultDomain() {
-                // TODO Auto-generated method stub
-                return null;
-            }
-
-            public String getHelloName() {
-                // TODO Auto-generated method stub
-                return null;
-            }
+       
+        handler.setDomainList(new SimpleDomainList() {
 
-            public String getId() {
-                // TODO Auto-generated method stub
-                return null;
-            }
-
-            public boolean supportVirtualHosting() {
-                // TODO Auto-generated method stub
-                return false;
-            }
-
-            public MailAddress getPostmaster() {
-                // TODO Auto-generated method stub
-                return null;
-            }
-            
-        });
-        handler.setDomainList(new DomainList() {
-
-            public boolean addDomain(String domain) {
-                // TODO Auto-generated method stub
-                return false;
-            }
 
             public boolean containsDomain(String domain) {
                 return domain.equals(VALID_DOMAIN);
             }
-
-            public String[] getDomains() {
-                // TODO Auto-generated method stub
-                return null;
-            }
-
-            public boolean removeDomain(String domain) {
-                // TODO Auto-generated method stub
-                return false;
-            }
-            
         });
     }
 
Index: user-api/src/main/java/org/apache/james/user/api/UserManagementMBean.java
===================================================================
--- user-api/src/main/java/org/apache/james/user/api/UserManagementMBean.java	(revision 1033370)
+++ user-api/src/main/java/org/apache/james/user/api/UserManagementMBean.java	(working copy)
@@ -149,4 +149,13 @@
      * @return List<String> of repository names
      */
     List<String> getUserRepositoryNames();
+    
+    /**
+     * Return true if the UserRepository has VirtualHosting enabled
+     * 
+     * @param repositoryName The user repository, to which the operation should be applied. If NULL, the LocalUsers
+     *        repository is used.
+     * @return virtual
+     */
+    public boolean getVirtualHostingEnabled(String repositoryName);
 }
Index: user-api/src/main/java/org/apache/james/user/api/UsersRepository.java
===================================================================
--- user-api/src/main/java/org/apache/james/user/api/UsersRepository.java	(revision 1033370)
+++ user-api/src/main/java/org/apache/james/user/api/UsersRepository.java	(working copy)
@@ -171,5 +171,14 @@
      * @return Iterator over a collection of Strings, each being one user in the repository.
      */
     Iterator<String> list();
+    
+    
+    
+    /**
+     * Return true if virtualHosting support is enabled, otherwise false
+     * 
+     * @return true or false
+     */
+    boolean supportVirtualHosting();
 
 }
Index: user-jcr/src/main/java/org/apache/james/user/jcr/JCRUsersRepository.java
===================================================================
--- user-jcr/src/main/java/org/apache/james/user/jcr/JCRUsersRepository.java	(revision 1033370)
+++ user-jcr/src/main/java/org/apache/james/user/jcr/JCRUsersRepository.java	(working copy)
@@ -60,6 +60,8 @@
 	private String workspace;
 
 	private Log logger;
+
+    private boolean virtualHosting;
 	
     @Resource(name="jcrRepository")
     public void setRepository(Repository repository) {
@@ -79,6 +81,8 @@
 		if (username != null && password != null) {
 			this.creds = new SimpleCredentials(username, password.toCharArray());
 		}
+        virtualHosting = config.getBoolean("enableVirtualHosting", false);
+
 	}
 
 
@@ -479,4 +483,12 @@
         return userNames.iterator();
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.user.api.UsersRepository#supportVirtualHosting()
+     */
+    public boolean supportVirtualHosting() {
+        return virtualHosting;
+    }
+
 }
Index: user-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java
===================================================================
--- user-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java	(revision 1045022)
+++ user-jpa/src/main/java/org/apache/james/user/jpa/JPAUsersRepository.java	(working copy)
@@ -52,6 +52,8 @@
 
     private Log logger;
 
+    private boolean virtualHosting;
+
 
     /**
      * Sets entity manager.
@@ -349,6 +351,8 @@
      */
     public void configure(HierarchicalConfiguration config) throws ConfigurationException {
         algo = config.getString("algorithm","MD5");
+        virtualHosting = config.getBoolean("enableVirtualHosting", false);
+
     }
 
     /*
@@ -368,4 +372,12 @@
         return entityManagerFactory.createEntityManager();
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.user.api.UsersRepository#supportVirtualHosting()
+     */
+    public boolean supportVirtualHosting() {
+        return virtualHosting;
+    }
+
 }
Index: user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
===================================================================
--- user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java	(revision 1033370)
+++ user-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java	(working copy)
@@ -607,4 +607,11 @@
         this.log = log;
     }
 
+    /**
+     * VirtualHosting not supported
+     */
+    public boolean supportVirtualHosting() {
+        return false;
+    }
+
 }
Index: user-library/src/main/java/org/apache/james/user/lib/AbstractJamesUsersRepository.java
===================================================================
--- user-library/src/main/java/org/apache/james/user/lib/AbstractJamesUsersRepository.java	(revision 1033370)
+++ user-library/src/main/java/org/apache/james/user/lib/AbstractJamesUsersRepository.java	(working copy)
@@ -69,6 +69,8 @@
 
     private Log logger;
 
+    private boolean virtualHosting;
+
     public void setLog(Log logger) {
         this.logger = logger;
     }
@@ -77,7 +79,8 @@
         setIgnoreCase(configuration.getBoolean("ignoreCase", false));
         setEnableAliases(configuration.getBoolean("enableAliases", false));
         setEnableForwarding(configuration.getBoolean("enableForwarding", false));
-        
+        virtualHosting = configuration.getBoolean("enableVirtualHosting", false);
+
         doConfigure(configuration);
     }
     
@@ -85,6 +88,9 @@
         
     }
 
+    public void setEnableVirtualHosting(boolean virtualHosting) {
+        this.virtualHosting = virtualHosting;
+    }
     /**
      * Adds a user to the underlying Repository. The user name must not clash
      * with an existing user.
@@ -274,4 +280,13 @@
         return new ArrayList<String>();
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.user.api.UsersRepository#supportVirtualHosting()
+     */
+    public boolean supportVirtualHosting() {
+        return virtualHosting;
+    }
+
+    
 }
Index: user-library/src/main/java/org/apache/james/user/lib/LocalUsersRepository.java
===================================================================
--- user-library/src/main/java/org/apache/james/user/lib/LocalUsersRepository.java	(revision 1033370)
+++ user-library/src/main/java/org/apache/james/user/lib/LocalUsersRepository.java	(working copy)
@@ -141,4 +141,13 @@
         return users.list();
     }
 
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.user.api.UsersRepository#supportVirtualHosting()
+     */
+    public boolean supportVirtualHosting() {
+        return users.supportVirtualHosting();
+    }
+
 }
Index: user-library/src/main/java/org/apache/james/user/lib/UserManagement.java
===================================================================
--- user-library/src/main/java/org/apache/james/user/lib/UserManagement.java	(revision 1033370)
+++ user-library/src/main/java/org/apache/james/user/lib/UserManagement.java	(working copy)
@@ -192,4 +192,12 @@
         return result;
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.james.user.api.UserManagementMBean#getVirtualHostingEnabled(java.lang.String)
+     */
+    public boolean getVirtualHostingEnabled(String repositoryName) {
+        return getUserRepository(repositoryName).supportVirtualHosting();
+    }
+
 }
