<?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.    
-->
<document>
  <properties>
    <title>Frequently Asked Questions</title>
    <author email="site-dev@james.apache.org">James Project Web Team</author>
  </properties>
  <body>
    <section name="This FAQ">
      <P>This is a living document that provides answers to common questions about James, installation, configuration, admin and running not already answered in the documentation. Last Updated January 2005.</P>
    </section>
    <section name="Questions">
      <p>
        <ul>
          <li>
            <a href="#1">How do I set up a mailing list</a>
          </li>
          <li>
            <a href="#2">Is James an Open Relay for Spam?</a>
          </li>
          <li>
            <a href="#3">I can send messages to James, but nobody is receiving them.  What do I do?</a>
          </li>
          <li>
            <a href="#4">I can send people messages via James, but nobody can send me messages.  What do I do?</a>
          </li>
          <li>
            <a href="#5">I'm trying to debug messages that James is trying to deliver.  Where should I look?</a>
          </li>
          <li>
            <a href="#6">What about IMAP support?</a>
          </li>
          <li>
            <a href="#7">What about support virtual hosting?</a>
          </li>
          <li>
            <a href="#8">Where do I stick classes and jars?</a>
          </li>
          <li>
            <a href="#9">How do I upgrade to a newer version of James?</a>
          </li>
          <li>
            <a href="#10">How do I run James as an NT/2k/XP service?</a>
          </li>
          <li>
            <a href="#11">Why isn't my mailet making changes to a MimeMessage?</a>
          </li>
          <li>
            <a href="#12">How to remove unneeded services like NNTP, POP3?</a>
          </li>
          <li>
            <a href="#13">How can I contribute to James?</a>
          </li>
          <li>
            <a href="#14">How can I make sendmail route local mail (or all mail) through James on the same machine?</a>
          </li>
          <li>
            <a href="#15">I am using Microsoft's SQL Type 4 JDBC Driver, why do I get a "Can't start manual transaction mode because there are cloned connections" exception?</a>
          </li>
          <li>
            <a href="#16">I am using James with a MySQL database and I keep getting a "Packet is larger than max_allowed_packet" when receiving large messages despite the fact that my max packet size is configured to be larger than my max message size.  What's going on?</a>
          </li>
          <li>
            <a href="#17">How do I use Subversion to get James source code?</a>
          </li>
        </ul>
      </p>
    </section>
    <section name="Answers">
      <a name="1"/>
      <subsection name="Would you please teach me how to set up a mailing list">
        <p>James currently (v2.1) includes only the most basic list functionality, users can subscribe and unsubscribe, but there is no moderation of messages or subscriptions</p>
        <p>To enable a list you need the following in config.xml in the root processor block and above the final mailet block -</p>
        <source>
&lt;mailet match="CommandForListserv=james@localhost"
    class="AvalonListservManager">
    &lt;repositoryName>list-james&lt;/repositoryName>
&lt;/mailet>
</source>
        <p>that will intercept the command emails sent to
<ul>
            <li>james-on@localhost to subscribe the sender</li>
            <li>james-off@localhost to unsubscribe the sender</li>
          </ul>
        </p>
        <p>and-</p>
        <source>
&lt;mailet match="RecipientIs=james@localhost" class="AvalonListserv">
    &lt;membersonly> false &lt;/membersonly>
    &lt;attachmentsallowed> true &lt;/attachmentsallowed>
    &lt;replytolist> true &lt;/replytolist>
    &lt;repositoryName>list-james&lt;/repositoryName>
    &lt;subjectprefix>JamesList&lt;/subjectprefix>
&lt;/mailet>
</source>
        <p>Which will distribute the mail to the current subscribers</p>
        <p>in addition to the above you need to have a repository configured in the users-store block(usually near the bottom of config.xml) like so (database)-</p>
        <source>
&lt;repository name="list-james"
    class="org.apache.james.userrepository.ListUsersJdbcRepository"
    destinationURL="db://maildb/lists/list-james">
    &lt;sqlFile>file://conf/sqlResources.xml&lt;/sqlFile>
&lt;/repository>
</source>
        <p>Database users will also need to ensure that they have <a href="using_database_2_1.html">configured a data-source</a> named to match the destination URL</p>
        <p>Using the filesystem:-</p>
        <source>
&lt;repository name="list-james"
    class="org.apache.james.userrepository.UsersFileRepository">
    &lt;destination URL="file://var/lists/list-james/"/>
&lt;/repository>
</source>
        <p>Restart James, send a mail to james-on@localhost and you should be subscribed.</p>
        <p>The repository, be it a database table or directory in the filesystem will be created automatically.</p>
        <p>Database users can manipulate the users repository using SQL, and hence any application capable of running SQL queries against it.</p>
      </subsection>
      <a name="2"/>
      <subsection name="James seems to be an open relay for Spam, is it?">
        <p>In some simple tests of mail relays James appears to be an open relay, properly configured it is not. </p>
        <p>Because James is an email application platform it currently accepts all mail delivered to it via SMTP for processing. Only after the mail has been recieved does this processing begin.</p>
        <p>This means that James accepts Spam. However the default configuration, and any sensible re-configuration has a number of anti-spam measures which will prevent the re-transmisson of spam from James. This makes it a blackhole for spam.</p>
        <p>This also means that James will not verify addresses, but of course this means that valid addresses can't be harvested from James by spammers either.</p>
      </subsection>
      <a name="3"/>
      <subsection name="I can send messages to James, but nobody is receiving them.  What do I do?">
        <p>Check that you've added valid DNS servers to your James installation.  Email delivery requires the use of special mail related DNS information (MX records), so James needs to explicitly be given DNS servers.  Look at your config.xml file for a &lt;dnsserver&gt; section and add one or more DNS servers.</p>
        <p>Additionally, check the RemoteAddrNotInNetwork matcher under&lt;processor name="transport"&gt;. By default it looks like this:</p>
        <source>
&lt;mailet match="RemoteAddrNotInNetwork=127.0.0.1" class="ToProcessor"&gt;
    &lt;processor&gt; spam &lt;/processor&gt;
&lt;/mailet&gt;
</source>
        <p>because most mail programs will use the external IP address (as opposed to 127.0.0.1) when processing mail, you need to add your internal network and/or your static IP address to this list.  You may also use a DNS domain name in this list.  The resulting entry would look something like this:</p>
        <source>
&lt;mailet match="RemoteAddrNotInNetwork=127.0.0.1,192.168.1.*"
        class="ToProcessor"&gt;
    &lt;processor&gt; spam &lt;/processor&gt;
&lt;/mailet&gt;
</source>
        <p>This tells the processor that anything not in this address list should go to the spam processor.</p>
        <p>Please note that if you wish to configure James to allow users to send email from any domain or IP address you will need to disable this matcher.  In this situation you must use SMTP AUTH to ensure that your server does not act as an open relay.  For more on open relays, please see <a href="http://www.ordb.org">the Open Relay Database</a>.</p>
      </subsection>
      <a name="4"/>
      <subsection name="I can send people messages via James, but nobody can send me messages.  What do I do?">
        <p>You need to do one of two things:
               <ol>
            <li>Update your domain's DNS entries so there are MX records that point to the machine that is running James.  Note that it is illegal for MX records to point to IP addresses.  You need to point MX records to a valid CNAME or A name entry, and then map that eventually to an IP address.</li>
            <li>You could alternatively give people an email address with IP addresses.  Most people will think it's a very strange email address, but hello@[192.168.0.1] is a valid email address.  Note that you need to wrap the IP address in brackets.</li>
          </ol>
        </p>
      </subsection>
      <a name="5"/>
      <subsection name="I'm trying to debug messages that James is trying to deliver.  Where should I look?">
        <p>First step is to look in the log directory at the mailet.log file.  Look for entries that include the text "RemoteDelivery".  This should provide some high-level debug information of James' attempt to delivery mail remotely.</p>
        <p>If you want to delve into the code, look at the RemoteDelivery mailet.  You may also want to review the mail repository source code for the repository type you are using (file, db, etc...).</p>
      </subsection>
      <a name="6"/>
      <subsection name="What about IMAP support?">
        <p>IMAP development had been stalled, but has recently attracted new activity.  IMAP support is scheduled for inclusion in James v3.  In the meantime, there is experimental code in the repository.  If you are interested in working on or trying the IMAP prototype code, join the james-dev mailing list and let us know.</p>
      </subsection>
      <a name="7"/>
      <subsection name="What about support virtual hosting?">
        <p>James v2.1 includes a new mailet for database users, <a href="javadocs/org/apache/james/transport/mailets/JDBCVirtualUserTable.html">JDBCVirtualUserTable</a>, that mimics some of the sendmail capabilities of the same name.</p>
        <p>JDBCVirtualUserTable does not provide any administation tools.
You'll have to create and maintain the database table yourself.  The
standard configuration is as follows:</p>
        <source>
CREATE TABLE VirtualUserTable
(
 user varchar(64) NOT NULL default '',
 domain varchar(255) NOT NULL default '',
 target_address varchar(255) NOT NULL default '',
 PRIMARY KEY (user,domain)
);
</source>
        <p>The standard query used with VirtualUserTable is:</p>
        <source>
select VirtualUserTable.target_address from VirtualUserTable, VirtualUserTable as VUTDomains
where (VirtualUserTable.user like ? or VirtualUserTable.user like "\%")
and (VirtualUserTable.domain like ?
or (VirtualUserTable.domain like "\%" and VUTDomains.domain like ?))
order by concat(VirtualUserTable.user,'@',VirtualUserTable.domain) desc limit 1
</source>
        <p>For a given [user, domain, domain] used with the query, this will
match as follows (in precedence order):
<ol>
            <li>user@domain    - explicit mapping for user@domain</li>
            <li>user@%         - catchall mapping for user anywhere</li>
            <li>%@domain       - catchall mapping for anyone at domain</li>
            <li>null           - no valid mapping</li>
          </ol>
        </p>
        <p>A sample mailet looks like:</p>
        <source>
&lt;mailet match="All" class="JDBCVirtualUserTable"&gt;
  &lt;table&gt;db://maildb/VirtualUserTable&lt;/table&gt;
&lt;/mailet&gt;
</source>
        <p>More generalized viirtual hosting is something the developers are still discussing.  One issue is that POP3 does not support virtual hosting in that it does not have a command to indicate what domain the user is in.  What this means is the mail server needs to support a 'mapping' or 'translation' convention, e.g., 'user1@domaina.com' gets a username 'domaina.user1'.  This allows the mail server to have a single username namespace.  We have seen a few good proposals put forward, but nothing that seemed the clear solution, as ideally we could have this part solve the next issue.</p>
        <p>Beyond that, James needs to refine virtual hosting for mailet processing.  With the current user model, the mailet API has a Mail.getUser() method that no longer would be useable as a reliable indicator of whether they were in the local username namespace.  To date we are unclear of the best way to bring this translation into the mailet processing.  Similarly, it would be nice to support different mailet processing based on the domain, although this is somewhat feasible using the limited processing flow offered with a HostIs matcher.</p>
        <p>Virtual hosting is one of the most requested features, and additional work is scheduled for the 3.0 release.</p>
      </subsection>
      <a name="8"/>
      <subsection name="Where do I stick classes and jars?">
        <p>We are largely reliant on what Avalon is doing in terms of classloading, but here are a few tips and suggestions:
  <ul>
            <li>Stick jars in the james/lib directory and add them to the classpath in run.bat or run.sh.</li>
            <li>Instructions for including classes for custom mailets and matchers can be found <a href="custom_mailet_2_1.html">here</a> and <a href="custom_matcher_2_1.html">here</a> respectively..</li>
          </ul>
  Eventually we hope to support mailet reloading and a special lib and classes directory within the james directory that custom mailets can load from, but for now these are hopefully some useful tips.</p>
      </subsection>
      <a name="9"/>
      <subsection name="How do I upgrade to a newer version of James?">
        <p>
          <ol>
            <li>Rename the previous james directory into a james.old</li>
            <li>Run phoenix to let the new james.sar be deployed.</li>
            <li>Edit the newly deployed config.xml to reflect your customizations from the previous config.xml.</li>
            <li>If using JDBC, see <a href="http://wiki.apache.org/james/UpgradingToAttributes">necessary table changes.</a>
            </li>
            <li>Replace the var directory by the previous var directory.  This will copy over user accounts, inboxes, spools, and whatever else.</li>
            <li>Restart James.</li>
          </ol>
        </p>
      </subsection>
      <a name="10"/>
      <subsection name="How do I run James as an NT/2k/XP service?">
        <p>The version of Avalon Phoenix distributed with James v2.1 and later includes a <a href="http://avalon.apache.org/phoenix/guide-administrator.html">wrapper</a> that lets you run James as a service.  An alternative strategy is to install the <a href="http://www.alexandriasc.com/software/JavaService/index.html">JavaService</a> from Alexandia Software.</p>
      </subsection>
      <a name="11"/>
      <subsection name="Why isn't my mailet making changes to a MimeMessage?">
        <p>Check the JavaMail docs.  Per the API, when you call MimeMessage.setContent(blah), you have to call saveChanges() to apply your changes.  James tries to automatically call this method so you don't have to, but in certain cases you'll still have to call saveChanges().</p>
      </subsection>
      <a name="12"/>
      <subsection name="How to remove unneeded services like NNTP, POP3?">
        <p>The following information is based on James 2.0a3, but the
             upcoming 2.1 version should be similar.</p>
        <p>NNTP and other underlying services are called "blocks" in the
             Avalon Phoenix terminology. Blocks are specified in the
             assembly.xml file which is located in the apps/james/SAR-INF directory (2.1)
             or apps/james/conf directory (2.0a3). Note: this file is created
             during the first startup of James.</p>
        <p>There are dependencies between the blocks, which you can read from
             the file. For example the SMTP Server block depends on the
             users-store block, so if you want SMTP then you cannot remove the
             users-store block even if you only want to relay messages.</p>
        <p>To remove the NNTP Server comment out the following blocks:
             NNTP server, NNTP Authentication Service, NNTP repository.
             To remove the POP3 Server comment out the POP3 Server block.</p>
        <p>If you remove a block it wont't be loaded next time you restart
             James. You must also remove all sections related to the removed
             blocks from the James configuration file - config.xml - otherwise
             you will get error messages, saying that there is no corresponding
             block.</p>
      </subsection>
      <a name="13"/>
      <subsection name="How can I contribute to James">
        <p>Read the "Contributors How To" <a href="contribute.html">here</a>
        </p>
      </subsection>
      <a name="14"/>
      <subsection name="How can I make sendmail route local mail (or all mail) through James on the same machine?">
        <p>Read the "sendmail How To" <a href="james_and_sendmail.html">here</a>
        </p>
      </subsection>
      <a name="15"/>
      <subsection name="I am using Microsoft's SQL Type 4 JDBC Driver, why do I get a &quot;Can't start manual transaction mode because there are cloned connections&quot; exception?">
        <p>I am using Microsoft's SQL Type 4 JDBC Driver, why do I get the following exception?<br/>java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Can&apos;t start manual transaction mode because there are cloned connections.</p>
        <p>This seems to be a problem with the Microsoft Type 4 JDBC Driver and concurrent statements/transactions/resultsets on the same database conntection.</p>
        <p>To solve this you need to add <b>;SelectMethod=cursor</b> to the end of your dburl string. Your dburl string would then look something like this<br/>&lt;dburl&gt;jdbc:microsoft:sqlserver://dbserver.host.name:1433;SelectMethod=cursor&lt;/dburl&gt;</p>
        <p>NOTE: some people have complained about performance when using this option, the alternative is a 3rd party JDBC driver but these are often not free.</p>
      </subsection>
      <a name="16"/>
      <subsection name="I am using James with a MySQL database and I keep getting a &quot;Packet is larger than max_allowed_packet&quot; when receiving large messages despite the fact that my max packet size is configured to be larger than my max message size.  What's going on?">
        <p>When a user tries to send a large message that is close to but not quite at the max message limit the send fails and an exception similar to the following appears in the log:</p>
        <p>Sent: 451 Error processing message:<br/>
            Exception spooling message: Exception caught while storing mail Container:<br/>
            java.lang.IllegalArgumentException: Packet is larger than max_allowed_packet<br/>
            from server configuration of 4193280 bytes;<br/>
              nested exception is:<br/>
                    java.lang.RuntimeException: Exception caught while storing mail<br/>
            Container: java.lang.IllegalArgumentException: Packet is larger than<br/>
            max_allowed_packet from server configuration of 4193280 bytes<br/>
        </p>
        <p>Because of how the JDBC driver is written, a 25%
            factor is necessary between the maximum message size and the max_packet_size
            to prevent the driver from throwing an exception.  So if you want a 4MB
            maximum message size, you need a 5MB max_packet size.  Or a 4MB
            max_packet_size allows only a 3.2MB max message.
            </p>
      </subsection>
      <a name="17"/>
        <subsection name="How do I use Subversion to get James source code?">
          <p>First of all read this: <a href="http://www.apache.org/dev/version-control.html">ASF Source Code</a>.
          <br/>Now go to <a href="http://subversion.tigris.org/">http://subversion.tigris.org/</a> and download a subversion client.
          <br/>James subversion repository is at <b>http://svn.apache.org/repos/asf/james/server</b>. Commiters use "https".
          <br/>You may want to search the web, our <a href="http://www.mail-archive.com/server-dev@james.apache.org/">dev</a> and <a href="http://www.mail-archive.com/server-user@james.apache.org/">user</a> mail archives or our <a href="http://wiki.apache.org/james">wiki</a> for more information.</p>
        </subsection>
    </section>
  </body>
</document>
