1.将用户信息保存到数据库而不是文件
<users-store>
<repository name="LocalUsers"
class="org.apache.james.userrepository.JamesUsersJdbcRepository"
destinationURL="db://maildb/users">
<sqlFile>file://conf/sqlResources.xml</sqlFile>
</repository>
</users-store>
<database-connections>
<data-source name="maildb"
class="org.apache.james.util.dbcp.JdbcDataSource">
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
<dburl>jdbc:sqlserver://localhost:1433;SelectMethod=Cursor;DatabaseName=JAMES
</dburl>
<user>sa</user>
<password>123@qwe</password>
<max>20</max>
</data-source>
</database-connections>
上述配置的前提是:在%james-2.3.2%lib下有相关的jdbc驱动包。
2.如何将发送的邮件保存到数据库
<!--文件方式
<inboxRepository>
<repository destinationURL="file://var/mail/inboxes/" type="MAIL"/>
</inboxRepository>-->
<!-- Alternative inbox repository definition for DB use. -->
<!-- The format for the destinationURL is "db://<data-source>/<table>" -->
<!-- <data-source> is the datasource name set up in the database-connections block, below -->
<!-- <table> is the name of the table to store user inboxes in -->
<!-- The user name is used as <repositoryName> for this repository config. -->
<!--database-->
<inboxRepository>
<repository destinationURL="db://maildb/inbox/" type="MAIL"/>
</inboxRepository>
还有一个就是
<spoolrepository destinationURL="db://maildb/spool/spool" type="SPOOL"/>