달력

122021  이전 다음

  •  
  •  
  •  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  

Apache James Setting

OS/LINUX 2006. 2. 23. 15:31

Apache James 2.1 Setting

mail server로 대다수 서버는 sendmail이라는 데몬을 사용하죠. 물론 qmail이나 다른 데몬들도 많이 나오고 있습니다. 그런데 굳이 java로 된 메일 서버를 쓸 이유까지 있을까도 생각할 수 있지만 이런 질문에 대한 답은 각자 찾아보도록 하기로 하고 james의 사용에 대해서 알아보자.

아쉬운 점은 현재까지 릴리즈된 James 2.1은 IMAP을 지원하지 않기 때문에 이를 이용한 기능은 구현이 어렵다. 하지만 3.0버젼에서는 IMAP을 지원한다고 하니 기대해볼만 하다.


 

James Download & Install

우선 James의 기반이 되는 Avalon과 James를 다음 사이트에서 다운로드 받아서 설치하는 과정이 필요하다.

Avalon :
http://avalon.apache.org/
James : http://james.apache.org/

※ Java 2 Platform, Standard Edition(J2SE)는 기본적으로 필요하다.

Console # gzip -d james-2.1.3.tar.gzConsole # tar xvf james-2.1.3.tarConsole # unzip Avalon-4.1.4-bin.zipConsole # mv james-2.1.3 /usr/local/ ← 원하는 위치로 옮긴다Console # mv Avalon-4.1.4 /usr/local/Console # ln -s /usr/local/james-2.1.3 jamesConsole # ln -s /usr/local/Avalon-4.1.4 avalon


 

Shell Configuration

Console # suConsole # vi /etc/profile ← bash가 아니면 그에 해당하는 설정 파일# /etc/profile…##### HOME SET ###############################################################export JAVA_HOME=/usr/local/java ← j2se의 위치 지정export AVALON_HOME=/usr/local/avalon ← avalon의 위치 지정export JAMES_HOME=/usr/local/james ← james의 위치 지정…#### CLASSPATH SET ###########################################################export CLASSPATH=./:$JAVA_HOME/lib/tools.jarexport CLASSPATH=$CLASSPATH:$AVALON_HOME/avalon-framework-4.1.4.jar…#### PATH SET ################################################################export PATH=$PATH:$JAVA_HOME/binexport PATH=$PATH:$JAMES_HOME/bin:wq

기본적인 세팅이 끝났으므로 제대로 동작하는지 테스트 해보자.

Console # cd $JAMES_HOME/bin/Console # chmod +x *.sh ← 만약 *.sh의 모드가 readonly일 경우에..Console # ./run.shUsing PHOENIX_HOME: /tmp/james-2.1.3Using PHOENIX_TMPDIR: /tmp/james-2.1.3/tempUsing JAVA_HOME: /usr/local/javaRunning Phoenix: Phoenix 4.0.1James 2.1.3Remote Manager Service started plain:4555POP3 Service started plain:110SMTP Service started plain:25NNTP Service started plain:119Fetch POP Disabled ← 이 결과와 같다면 정상적으로 동작하는 것이다.JVM exiting abnormally. Shutting down Phoenix. ← CTRL+C를 누르면...


 

Repository Setting

사용자 로긴과 패스워드를 담고 있는 User Repository와 MailBox/Spool에 대한 정보와 메일 메시지를 담고 있든 Mail/Spool Repository는 기본적으로 파일 시스템으로 운영되지만 설정하기에 따라 JDBC를 지원하는 RDBMS(mysql, oracle, etc)에 저장할 수 있다. 이하 부분에서는 RDBMS로 ORACLE을 사용하는 설정에 대해 알아보자. 이를 위해서 Oracle 9i JDBC Driver를 받아야 한다.

Console # mv classes12.jar $JAMES_HOME/lib/ Console # mv nls_charset12.jar $JAMES_HOME/lib/

그외에 필요한 package의 경우도 이와 마찬가지로 $JAMES_HOME/lib/ 폴더에 넣으면 된다.

Console # cd $JAMES_HOME/apps/james/SAR-INF/vi config.xml

config.xml을 다음과 같이 수정하면 된다.

# $JAMES_HOME/apps/james/SAR-INF/config.xml<?xml version="1.0"?><!-- Configuration file for the Apache Jakarta James server --><!-- This file contains important settings that control the behaviour --><!-- of all of the services and repositories. --><!-- README! --><!-- This configuration file is designed to run without alteration for simple tests. --><!-- It assumes you have a DNS server on localhost and assigns a root password of root. --><!-- In case the defaults do not suit you, the items you are most likely to need to change --><!-- are preceded by a CHECKME! or CONFIRM? comment in the left margin. --><!-- For production use you will probably need to make more extensive changes, see --><!-- http://james.apache.org/documentation_2_1.html --><!-- $Revision: 1.40.2.5 $ Committed on $Date: 2003/05/12 21:10:24 $ by: $Author: noel $ --><config> <James><!-- 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> <!-- servernames identifies the DNS namespace served by this instance of James. --> <!-- These servernames are used for both matcher/mailet processing and SMTP auth --> <!-- to determine when a mail is intended for local delivery. --> <!-- --> <!-- If autodetect is TRUE, James wil attempt to discover its own host name AND --> <!-- use any explicitly specified servernames. --> <!-- If autodetect is FALSE, James will use only the specified servernames. --> <!-- --> <!-- If autodetectIP is not FALSE, James will also allow add the IP address for each servername. --> <!-- The automatic IP detection is to support RFC 2821, Sec 4.1.3, address literals. --> <!-- --> <!-- To override autodetected server names simply add explicit servername elements. --> <!-- In most cases this will be necessary. --> <!-- By default, the servername 'localhost' is specified. This can be removed, if required. --> <!-- --> <!-- Warning: If you are using fetchpop it is important to include the --> <!-- fetched domains in the server name list to prevent looping. --> <servernames autodetect="true" autodetectIP="true"><!-- CONFIRM? --> <servername>localhost</servername> <servername>apple</servername> </servernames> <!-- Set whether user names are case sensitive or case insensitive --> <!-- Set whether to enable local aliases --> <!-- Set whether to enable forwarding --> <usernames ignoreCase="true" enableAliases="true" enableForwarding="true"/> <!-- The inbox repository is the location for users inboxes --> <!-- Default setting: file based repository - enter path ( use "file:///" for absolute) --><!-- <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. --> <inboxRepository> <repository destinationURL="db://maildb/inbox/" type="MAIL"/> </inboxRepository> <!-- Alternative inbox repository definition for DB use. --> <!-- Stores message body in file system, rest in database --> <!-- <inboxRepository> <repository destinationURL="dbfile://maildb/inbox/" type="MAIL"/> </inboxRepository> --> </James> <!-- Fetch pop block, fetches mail from POP3 servers and inserts it into the incoming spool --> <!-- Warning: It is important to prevent mail from looping by setting the --> <!-- fetched domains in the <servernames> section of the <James> block --> <!-- above. This block is disabled by default. --> <fetchpop enabled="false"> <!-- You can have as many fetch tasks as you want, but each must have a --> <!-- unique name by which it identified --> <fetch name="mydomain.com"> <!-- Host name or IP address --> <host>mail.mydomain.com</host> <!-- Account login username --> <user>username</user> <!-- Account login password --> <password>pass</password> <!-- How frequently this account is checked - in milliseconds. 600000 is every ten minutes --> <interval>600000</interval> </fetch> </fetchpop> <!-- The James Spool Manager block --> <!-- --> <!-- This block is responsible for processing messages on the spool. --> <spoolmanager> <!-- Number of spool threads --> <threads> 10 </threads> <!-- Set the Java packages from which to load mailets and matchers --> <mailetpackages> <mailetpackage>org.apache.james.transport.mailets</mailetpackage> </mailetpackages> <matcherpackages> <matcherpackage>org.apache.james.transport.matchers</matcherpackage> </matcherpackages> <!-- The root processor is a required processor - James routes all mail on the spool --> <!-- through this processor first. --> <!-- --> <!-- This configuration is a sample configuration for the root processor. --> <processor name="root"> <!-- Checks that the email Sender is associated with a valid domain. --> <!-- Useful for detecting and eliminating spam. --> <!-- For this block to function, the spam processor must be configured. --> <!-- <mailet match="SenderInFakeDomain" class="ToProcessor"> <processor> spam </processor> </mailet> --> <!-- Important check to avoid looping --> <mailet match="RelayLimit=30" class="Null"/> <!-- White List: If you use block lists, you will probably want to check for known permitted senders. This is particularly true if you use more aggressive block lists, such as SPEWS, that are prone to block entire subnets without regard for non-spamming senders. --> <!-- specific known senders --> <!-- <mailet match="SenderIs=goodboy@goodhost" class="ToProcessor"> <processor> transport </processor> </mailet> --> <!-- People on this list agree to pay a penalty if they send spam --> <mailet match="InSpammerBlacklist=query.bondedsender.org" class="ToProcessor"> <processor> transport </processor> </mailet> <!-- E-mail legally required not to be spam (see: http://www.habeas.com) --> <!-- <mailet match="HasHabeasWarrantMark" class="ToProcessor"> <processor> transport </processor> </mailet> --> <!-- End of White List --> <!-- Check for delivery from a known spam server --> <!-- This set of matchers/mailets redirect all emails from known --> <!-- black holes, open relays, and spam servers to the spam processor --> <!-- For this set to function properly, the spam processor must be configured. --> <mailet match="InSpammerBlacklist=dnsbl.njabl.org" class="ToProcessor"> <processor> spam </processor> <notice>550 Requested action not taken: rejected - see http://njabl.org/ </notice> </mailet> <mailet match="InSpammerBlacklist=relays.ordb.org" class="ToProcessor"> <processor> spam </processor> <notice>550 Requested action not taken: rejected - see http://www.ordb.org/ </notice> </mailet> <!-- Sample matching to kill a message (send to Null) --> <!-- <mailet match="RecipientIs=badboy@badhost" class="Null"/> --> <!-- Send remaining mails to the transport processor for either local or remote delivery --> <mailet match="All" class="ToProcessor"> <processor> transport </processor> </mailet> </processor> <!-- The error processor is required. James may internally set emails to the --> <!-- error state. The error processor is generally invoked when there is an --> <!-- unexpected error either in the mailet chain or internal to James. --> <!-- --> <!-- By default configuration all email that generates an error in placed in --> <!-- an error repository. --> <processor name="error"> <!-- Logs any messages to the repository specified --> <mailet match="All" class="ToRepository"><!-- <repositoryPath> file://var/mail/error/</repositoryPath>--> <!-- An alternative database repository example follows. --> <repositoryPath> db://maildb/deadletter/error </repositoryPath> <passThrough> true </passThrough> </mailet> <!-- If you want to notify the sender their message generated an error, uncomment this --> <!-- <mailet match="All" class="NotifySender"/> --> <!-- If you want to notify the postmaster that a message generated an error, uncomment this --> <!-- <mailet match="All" class="NotifyPostmaster"/> --> </processor> <!-- Processor CONFIGURATION SAMPLE: transport is a sample custom processor for local or --> <!-- remote delivery --> <processor name="transport"> <!-- Is the recipient is for a local account, deliver it locally --> <mailet match="RecipientIsLocal" class="LocalDelivery"/> <!-- If the host is handled by this server and it did not get --> <!-- locally delivered, this is an invalid recipient --> <mailet match="HostIsLocal" class="ToProcessor"> <processor>error</processor> </mailet><!-- CHECKME! --> <!-- This is an anti-relay matcher/mailet combination --> <!-- --> <!-- Emails sent from servers not in the network list are --> <!-- rejected as spam. This is one method of preventing your --> <!-- server from being used as an open relay. Make sure you understand --> <!-- how to prevent your server from becoming an open relay before --> <!-- changing this configuration. --> <!-- --> <!-- This matcher/mailet combination must come after local delivery has --> <!-- been performed. Otherwise local users will not be able to receive --> <!-- email from senders not in this remote address list. --> <!-- --> <!-- If you are using this matcher/mailet you will probably want to --> <!-- update the configuration to include your own network/addresses. The --> <!-- matcher can be configured with a comma separated list of IP addresses --> <!-- wildcarded IP subnets, and wildcarded hostname subnets. --> <!-- e.g. "RemoteAddrNotInNetwork=127.0.0.1, abc.de.*, 192.168.0.*" --> <!-- --> <!-- If you are using SMTP authentication then you can (and generally --> <!-- should) disable this matcher/mailet pair. --> <mailet match="RemoteAddrNotInNetwork=127.0.0.1" class="ToProcessor"> <processor> spam </processor> </mailet> <!-- Attempt remote delivery using the specified repository for the spool, --> <!-- using delay time to retry delivery and the maximum number of retries --> <mailet match="All" class="RemoteDelivery"><!-- <outgoing> file://var/mail/outgoing/ </outgoing>--> <!-- alternative database repository example below --> <outgoing> db://maildb/spool/outgoing </outgoing> <!-- Number of milliseconds between delivery attempts --> <delayTime> 21600000 </delayTime> <!-- Number of failed attempts before returning to the sender --> <maxRetries> 5 </maxRetries> <!-- The number of threads that should be trying to deliver outgoing messages --> <deliveryThreads> 1 </deliveryThreads> <!-- A single mail server to deliver all outgoing messages. --> <!-- This is useful if this server is a backup or failover machine, --> <!-- or if you want all messages to be routed through a particular mail server, --> <!-- regardless of the email addresses specified in the message --> <!-- --> <!-- The gateway element specifies the gateway SMTP server name. --> <!-- If your gateway mail server is listening on a port other than 25, --> <!-- you can set James to connect to it on that port using the gatewayPort --> <!-- element. --> <!-- <gateway> otherserver.mydomain.com </gateway> <gatewayPort>25</gatewayPort> --> </mailet> </processor> <!-- Processor CONFIGURATION SAMPLE: spam is a sample custom processor for handling --> <!-- spam. --> <!-- You can either log these, bounce these, or just ignore them. --> <processor name="spam"> <!-- To destroy all messages, uncomment this matcher/mailet configuration --> <!-- <mailet match="All" class="Null"/> --> <!-- To notify the sender their message was marked as spam, uncomment this matcher/mailet configuration --> <!-- <mailet match="All" class="NotifySender"/> --> <!-- To notify the postmaster that a message was marked as spam, uncomment this matcher/mailet configuration --> <!-- <mailet match="All" class="NotifyPostmaster"/> --> <!-- To log the message to a repository, this matcher/mailet configuration should be uncommented. --> <!-- This is the default configuration. --> <mailet match="All" class="ToRepository"><!-- <repositoryPath>file://var/mail/spam/</repositoryPath>--> <!-- Changing the repositoryPath, as in this commented out example, will --> <!-- cause the mails to be stored in a database repository. --> <!-- Please note that only one repositoryPath element can be present for the mailet --> <!-- configuration. --> <repositoryPath> db://maildb/deadletter/spam </repositoryPath> </mailet> </processor> </spoolmanager> <!-- DNS Server Block --> <!-- --> <!-- Specifies DNS Server information for use by various components inside --> <!-- James. --> <!-- --> <!-- Information includes a list of DNS Servers to be used by James. These are --> <!-- specified by the server elements, each of which is a child element of the --> <!-- servers element. Each server element is the IP address of a single DNS server. --> <!-- The servers element can have multiple server children. --> <dnsserver> <servers><!-- CONFIRM? --> <!--Enter ip address of your DNS server, one IP address per server --> <!-- element. The default configuration assumes a DNS server on the localhost. --> <server>127.0.0.1</server> <server>211.175.55.95</server> ← your dns </servers> <authoritative>false</authoritative> </dnsserver> <remotemanager> <port>4555</port> <!-- Uncomment this if you want to bind to a specific inetaddress --> <!-- <bind> </bind> --> <!-- Uncomment this if you want to use TLS (SSL) on this port --> <!-- <useTLS>true</useTLS> --> <handler> <!-- 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. --> <helloName autodetect="true">myMailServer</helloName> <administrator_accounts><!-- CHECKME! --> <!-- Change the default login/password. --> <account login="root" password="root"/> </administrator_accounts> <connectiontimeout> 60000 </connectiontimeout> </handler> </remotemanager> <!-- The POP3 server is enabled by default --> <!-- Disabling blocks will stop them from listening, --> <!-- but does not free as many resources as removing them would --> <pop3server enabled="true"> <!-- port 995 is the well-known/IANA registered port for POP3S ie over SSL/TLS --> <!-- port 110 is the well-known/IANA registered port for Standard POP3 --> <port>110</port> <!-- Uncomment this if you want to bind to a specific inetaddress --> <!-- <bind> </bind> --> <!-- Uncomment this if you want to use TLS (SSL) on this port --> <!-- <useTLS>true</useTLS> --> <handler> <!-- This is the name used by the server to identify itself in the POP3 --> <!-- 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. --> <helloName autodetect="true">myMailServer</helloName> <connectiontimeout>120000</connectiontimeout> </handler> </pop3server> <!-- The SMTP server is enabled by default --> <!-- Disabling blocks will stop them from listening, --> <!-- but does not free as many resources as removing them would --> <smtpserver enabled="true"> <!-- port 25 is the well-known/IANA registered port for SMTP --> <port>25</port> <!-- Uncomment this if you want to bind to a specific inetaddress --> <!-- <bind> </bind> --> <!-- Uncomment this if you want to use TLS (SSL) on this port --> <!-- <useTLS>true</useTLS> --> <handler> <!-- This is the name used by the server to identify itself in the SMTP --> <!-- 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. --> <helloName autodetect="true">myMailServer</helloName> <connectiontimeout>360000</connectiontimeout> <!-- Uncomment this if you want to require SMTP authentication. --> <!-- <authRequired>true</authRequired> --> <!-- Uncomment this if you want to verify sender addresses, ensuring that --> <!-- the sender address matches the user who has authenticated. --> <!-- This prevents a user of your mail server from acting as someone else --> <!-- <verifyIdentity>true</verifyIdentity> --> <!-- This sets the maximum allowed message size (in kilobytes) for this --> <!-- SMTP service. If unspecified, the value defaults to 0, which means no limit. --> <maxmessagesize>0</maxmessagesize> </handler> </smtpserver> <!-- The NNTP server is enabled by default --> <!-- Disabling blocks will stop them from listening, --> <!-- but does not free as many resources as removing them would --> <!-- NNTP-specific: if you disable the NNTP Server, you should also set the nntp-repository's threadCount to 0, otherwise there will be threads active and polling --> <nntpserver enabled="true"> <!-- THE NNTP PROTOCOL IS EXPERIMENTAL AND NOT AS WELL TESTED AS SMTP AND POP3 IN THIS RELEASE. The James project recommends that you check the James web site for updates to the NNTP service. --> <!-- port 563 is the well-known/IANA registered port for NNTP over SSL/TLS --> <!-- port 119 is the well-known/IANA registered port for Standard NNTP --> <port>119</port> <!-- Uncomment this if you want to bind to a specific inetaddress --> <!-- <bind> </bind> --> <!-- Uncomment this if you want to use TLS (SSL) on this port --> <!-- <useTLS>true</useTLS> --> <handler> <!-- This is the name used by the server to identify itself in the NNTP --> <!-- 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. --> <helloName autodetect="true">myMailServer</helloName> <connectiontimeout>120000</connectiontimeout> <!-- Set the authRequired value to true to enable authenticated NNTP --> <authRequired>false</authRequired> </handler> </nntpserver> <nntp-repository> <!-- If this is set to true, posting will be disallowed. --> <readOnly>false</readOnly> <rootPath>file://var/nntp/groups</rootPath> <tempPath>file://var/nntp/temp</tempPath> <articleIDPath>file://var/nntp/articleid</articleIDPath> <articleIDDomainSuffix>news.james.apache.org</articleIDDomainSuffix> <!-- The news groups hosted in this NNTP repository. --> <newsgroups> <newsgroup>org.apache.james.dev</newsgroup> <newsgroup>org.apache.james.user</newsgroup> <newsgroup>org.apache.avalon.dev</newsgroup> <newsgroup>org.apache.avalon.user</newsgroup> </newsgroups> <spool> <configuration> <spoolPath>file://var/nntp/spool</spoolPath> <!-- The number of threads that process spooler related tasks. --> <threadCount>1</threadCount> <!-- The spool thread(s) should idle for some time, if it has nothing to do --> <threadIdleTime>60000</threadIdleTime> </configuration> </spool> </nntp-repository> <!-- The Mailstore block --> <mailstore> <repositories> <!-- File based repositories. These repositories store all message data --> <!-- in the file system. --> <repository class="org.apache.james.mailrepository.AvalonMailRepository"> <protocols> <protocol>file</protocol> </protocols> <types> <type>MAIL</type> </types> </repository> <repository class="org.apache.james.mailrepository.AvalonSpoolRepository"> <protocols> <protocol>file</protocol> </protocols> <types> <type>SPOOL</type> </types> </repository> <!-- JDBC based repositories. These repositories store all message data --> <!-- in the database. --> <repository class="org.apache.james.mailrepository.JDBCMailRepository"> <protocols> <protocol>db</protocol> </protocols> <types> <type>MAIL</type> </types> <config> <sqlFile>file://conf/sqlResources.xml</sqlFile> </config> </repository> <repository class="org.apache.james.mailrepository.JDBCSpoolRepository"> <protocols> <protocol>db</protocol> </protocols> <types> <type>SPOOL</type> </types> <config> <sqlFile>file://conf/sqlResources.xml</sqlFile> </config> </repository> <!-- These repositories store message delivery and headers in the DB, and the body to the filesystem --> <repository class="org.apache.james.mailrepository.JDBCMailRepository"> <protocols> <protocol>dbfile</protocol> </protocols> <types> <type>MAIL</type> </types> <config> <sqlFile>file://conf/sqlResources.xml</sqlFile> <filestore>file://var/dbmail</filestore> </config> </repository> <repository class="org.apache.james.mailrepository.JDBCSpoolRepository"> <protocols> <protocol>dbfile</protocol> </protocols> <types> <type>SPOOL</type> </types> <config> <sqlFile>file://conf/sqlResources.xml</sqlFile> <filestore>file://var/dbmail</filestore> </config> </repository> </repositories> <!-- Spool repository configuration --> <!-- The spool repository is the location where incoming mails are temporarily stored --> <!-- before being processed. --><!-- <spoolRepository> <repository destinationURL="file://var/mail/spool/" type="SPOOL"/> </spoolRepository>--> <!-- Alternative spool repository definition for JDBC use --> <spoolRepository> <repository destinationURL="db://maildb/spool/spool" type="SPOOL"/> </spoolRepository> <!-- Alternative spool repository definition for JDBC use --> <!-- Stores message body in file system, rest in database --> <!-- <spoolRepository> <repository destinationURL="dbfile://maildb/spool/spool" type="SPOOL"/> </spoolRepository> --> </mailstore> <!-- The User Storage block --> <users-store> <!-- Configure User Repositories here. --> <!-- --> <!-- User repositories are required for the following purposes: --> <!-- - storing James user information, including forwards, aliases, --> <!-- and authentication data. --> <!-- - holding lists of users for the listserv mailet --> <!-- Currently, two different storage options are available: --> <!-- - file-based storage using Java serialization --> <!-- - database-backed storage --> <!-- (Use of database or file-system is defined on a "per-repository" basis) --> <!-- --> <!-- Note: One user repository is required for James: --> <!-- LocalUsers - the users for whom you are providing POP3, NNTP, or SMTP service --> <!-- --> <!-- Other repositories may be used by matchers or mailets. --> <!-- Default: File-based user repositories Use these configurations to store user info in the filesystem --> <!-- The LocalUsers repository, for storing James' User info. --><!-- <repository name="LocalUsers" class="org.apache.james.userrepository.UsersFileRepository"> <destination URL="file://var/users/"/> </repository>--> <!-- Database backed user repositories --> <!-- --> <!-- Use these configurations to store user info in a database. --> <!-- Note: The <data-source> element must refer to a connection configured --> <!-- in the <database-connections> configuration section. --> <!-- The LocalUsers repository, for storing James' User info. --> <repository name="LocalUsers" class="org.apache.james.userrepository.JamesUsersJdbcRepository" destinationURL="db://maildb/users"> <sqlFile>file://conf/sqlResources.xml</sqlFile> </repository> </users-store> <!-- The database-connections block --> <database-connections> <!-- These connections are referred to by name elsewhere in the config file --><!-- CHECKME! --> <!-- To allow James to use a database you must configure the database connection here. --> <!-- If you are not using a database, you can leave this section unchanged. --> <!-- These connections are referred to by name in URLs elsewhere in the config file. --> <data-sources> <!-- James is distributed with a built in relevant copy of the mm.mysql JDBC --> <!-- driver. No additional driver is needed for mysql. Read the mm.mysql LGPL --> <!-- license at apps\james\SAR-INF\lib\mm.mysql.LICENCE --> <!-- JDBC driver .jar libraries for other RDBMS can be placed in ~james/lib/ --> <!-- Example, connecting to a MySQL database called "mail" on localhost--> <!-- --> <!-- The max value is the maximum number of concurrent connections James will --> <!-- open to this database--> <!-- If you see "SQLException: Giving up... no connections available." in your --> <!-- log files or bounced mail you should increase this value --> <!-- <data-source name="maildb" class="org.apache.james.util.mordred.JdbcDataSource"> <driver>org.gjt.mm.mysql.Driver</driver> <dburl>jdbc:mysql://127.0.0.1/mail?autoReconnect=true</dburl> <user>username</user> <password>password</password> <max>20</max> </data-source> --> <data-source name="maildb" class="org.apache.james.util.mordred.JdbcDataSource"> <driver>oracle.jdbc.driver.OracleDriver</driver> <dburl>jdbc:oracle:thin:@127.0.0.1:1521:mail</dburl> ← @ Oracle Server Address : port number : SID <user>mail</user> ← user login <password>mail</password> ← user passwd <max>20</max> </data-source> <!-- Example, connecting to a Microsoft MSSQL database called "mail" on localhost--> <!-- --> <!-- The max value is the maximum number of concurrent connections James will --> <!-- open to this database--> <!-- If you see "SQLException: Giving up... no connections available." in your --> <!-- log files or bounced mail you should increase this value --> <!-- <data-source name="maildb" class="org.apache.james.util.mordred.JdbcDataSource"> <driver>com.inet.tds.TdsDriver</driver> <dburl>jdbc:inetdae7:127.0.0.1?database=James</dburl> <user>sa_james</user> <password>blahblah</password> <max>20</max> </data-source> --> </data-sources> </database-connections> <!-- Configuration for Cornerstone Services --> <!-- --> <!-- For a simple configuration, nothing beneath this line should require --> <!-- alteration. --> <!-- --> <!-- You will need to adjust the Socket Manager service configuration if you want --> <!-- to enable secure sockets (TLS) for any James service. --> <!-- --> <!-- Complex or high volume configurations may require changes to the parameters --> <!-- in this section. Please read the James and Avalon documentation before --> <!-- attempting to adjust this section. --> <!-- --> <!-- The Object Storage block --> <!-- --> <!-- Defines file storage details that are used for file-based repositories. --> <objectstorage> <repositories> <repository class="org.apache.james.mailrepository.filepair.File_Persistent_Object_Repository"> <protocols> <protocol>file</protocol> </protocols> <types> <type>OBJECT</type> </types> <models> <model>SYNCHRONOUS</model> <model>ASYNCHRONOUS</model> <model>CACHE</model> </models> </repository> <repository class="org.apache.james.mailrepository.filepair.File_Persistent_Stream_Repository"> <protocols> <protocol>file</protocol> </protocols> <types> <type>STREAM</type> </types> <models> <model>SYNCHRONOUS</model> <model>ASYNCHRONOUS</model> <model>CACHE</model> </models> </repository> </repositories> </objectstorage> <!-- The Connection Manager block --> <!-- --> <!-- The idle-timeout is the number of milliseconds that it will take for idle --> <!-- client connections managed by this connection manager to be marked at timed out. --> <!-- If no value is specified, the value defaults to 5 minutes, 300000 milliseconds --> <!-- A value of 0 means that client sockets will not timeout. --> <!-- --> <!-- The max-connections parameter specifies the default maximum number of client --> <!-- connections that this connection manager will allow per managed server socket. --> <!-- This value can be overridden by each individual service. --> <!-- If no value is specified, the value defaults to 30. --> <!-- A value of 0 means that there is no limit imposed by the connection manager, although --> <!-- resource limitations imposed by other components (i.e. max # of threads) may --> <!-- serve to limit the number of open connections. --> <!-- --> <connections> <idle-timeout>300000</idle-timeout> <max-connections>30</max-connections> </connections> <!-- The Socket Manager block --> <!-- --> <!-- The server-sockets element has a number of factory sub-elements. --> <!-- Each of the factory elements has a name and class attribute --> <!-- The name attribute for each factory element must be unique. --> <!-- The class attribute is the name of a class that implements the --> <!-- interface org.apache.avalon.cornerstone.services.ServerSocketFactory --> <!-- Specific factory elements may require some sub-elements. This is --> <!-- factory class dependent. --> <!-- --> <!-- The client-sockets element has a number of factory sub-elements. --> <!-- Each of the factory elements has a name and class attribute --> <!-- The name attribute for each factory element must be unique. --> <!-- The class attribute is the name of a class that implements the --> <!-- interface org.apache.avalon.cornerstone.services.SocketFactory --> <!-- Specific factory elements may require some sub-elements. This is --> <!-- factory class dependent. --> <!-- --> <sockets> <server-sockets> <factory name="plain" class="org.apache.avalon.cornerstone.blocks.sockets.DefaultServerSocketFactory"/> <!-- <factory name="ssl" class="org.apache.avalon.cornerstone.blocks.sockets.TLSServerSocketFactory"> <keystore> <file>conf/keystore</file> <password>secret</password> <type>JKS</type> <protocol>TLS</protocol> <algorithm>SunX509</algorithm> <authenticate-client>false</authenticate-client> </keystore> </factory> --> </server-sockets> <client-sockets> <factory name="plain" class="org.apache.avalon.cornerstone.blocks.sockets.DefaultSocketFactory"/> </client-sockets> </sockets> <!-- The Thread Manager block --> <!-- --> <!-- The thread manager provides thread pools for use throughout the server. --> <!-- --> <!-- A thread pool with the name "default" must be defined in this thread manager --> <!-- configuration. --> <!-- --> <!-- Each thread pool is defined with a "thread-group" element. --> <!-- Each of these elements has the following required sub-elements: --> <!-- name - the name of the thread pool, used by other components to --> <!-- lookup the thread pool --> <!-- priority - the thread priority for threads in the pool. This is --> <!-- a value between 0 and 10, with 5 being the normal --> <!-- priority and 10 being the maximum. --> <!-- is-daemon - whether the threads in the pool are daemon threads. --> <!-- max-threads - the maximum number of threads allowed in the pool. --> <!-- min-threads - the minimum number of threads allowed in the pool. (not implemented) --> <!-- min-spare-threads - (not implemented) --> <thread-manager> <thread-group> <name>default</name> <priority>5</priority> <is-daemon>false</is-daemon> <max-threads>100</max-threads> <min-threads>20</min-threads> <min-spare-threads>20</min-spare-threads> </thread-group> </thread-manager></config>


 

Daemon Script

시스템 부팅시 자동으로 실행하기 위한 boot script을 작성하면 Process의 관리가 수월하다.

Console # cd $JAMES_HOME/bin/Console # vi james_daemon.sh

james_daemon.sh의 내용은 다음과 같다..

# $JAMES_HOME/bin/james_daemon.sh#!/bin/sh## go.sh# Shell script to start and stop James# OS specific support. $var _must_ be set to either true or false.cygwin=falsecase "`uname`" inCYGWIN*) cygwin=true;;esac# Checking for JAVA_HOME is required on *nixif [ "$JAVA_HOME" = "" ] ; then export JAVA_HOME=/usr/java echo "ERROR: JAVA_HOME not found in your environment." echo echo "Please, set the JAVA_HOME variable in your environment to match the" echo "location of the Java Virtual Machine you want to use." echo "Trying to use /usr/java as default" exit 1fiJAVACMD=$JAVA_HOME/bin/java# resolve links - $0 may be a softlinkTHIS_PROG="$0"while [ -h "$THIS_PROG" ]; do ls=`ls -ld "$THIS_PROG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then THIS_PROG="$link" else THIS_PROG=`dirname "$THIS_PROG"`/"$link" fidone# Get standard environment variablesPRGDIR=`dirname "$THIS_PROG"`PHOENIX_HOME=`cd "$PRGDIR/.." ; pwd`unset THIS_PROG# For Cygwin, ensure paths are in UNIX format before anything is touchedif $cygwin; then [ -n "$PHOENIX_HOME" ] && PHOENIX_HOME=`cygpath --unix "$PHOENIX_HOME"`fiif [ -z "$PHOENIX_TMPDIR" ] ; then# Define the java.io.tmpdir to use for Phoenix PHOENIX_TMPDIR="$PHOENIX_HOME"/temp mkdir -p "$PHOENIX_TMPDIR"fi# For Cygwin, switch paths to Windows format before running javaif $cygwin; then PHOENIX_HOME=`cygpath --path --windows "$PHOENIX_HOME"`fi# ----- Execute The Requested Command -----------------------------------------echo "Using PHOENIX_HOME: $PHOENIX_HOME"echo "Using PHOENIX_TMPDIR: $PHOENIX_TMPDIR"echo "Using JAVA_HOME: $JAVA_HOME"## Command to override JVM ext dir## This is needed as some JVM vendors # like placing jaxp/jaas/xml-parser jars in ext dir# thus breaking Phoenix#JVM_OPTS="-Djava.ext.dirs=$PHOENIX_HOME/lib"if [ "$PHOENIX_SECURE" != "false" ] ; then# Make phoenix run with security manager enabled JVM_OPTS="$JVM_OPTS -Djava.security.manager"fiif [ "$1" = "start" ] ; then shift $JAVACMD $JVM_OPTS \ $JVM_OPTS \ -Djava.security.policy=jar:file:$PHOENIX_HOME/bin/phoenix-loader.jar!/META-INF/java.policy \ $PHOENIX_JVM_OPTS \ -Dphoenix.home="$PHOENIX_HOME" \ -Djava.io.tmpdir="$PHOENIX_TMPDIR" \ -jar "$PHOENIX_HOME/bin/phoenix-loader.jar" $* > /dev/null 2>&1 & echo $! > /var/run/james.pid elif [ "$1" = "stop" ] ; then shift kill -15 `cat /var/run/james.pid` rm -rf /var/run/james.pid elif [ "$1" = "run" ] ; then shift $JAVACMD $JVM_OPTS \ $JVM_OPTS \ -Djava.security.policy=jar:file:$PHOENIX_HOME/bin/phoenix-loader.jar!/META-INF/java.policy \ $PHOENIX_JVM_OPTS \ -Dphoenix.home="$PHOENIX_HOME" \ -Djava.io.tmpdir="$PHOENIX_TMPDIR" \ -jar "$PHOENIX_HOME/bin/phoenix-loader.jar" $* "$@" else echo "Usage:" echo "james (start|run|stop)" echo " start - start james in the background" echo " run - start james in the foreground" echo " stop - stop james" exit 0 fi

james_daemon.sh의 작성이 끝났으면 실행모드로 바꾼다.

Console # chmod +x james_daemon.sh

/etc/rc.d/init.d/에 추가될 script은 다음과 같이 작성한다.

Console # cd /etc/rc.d/init.d/Console # vi james

james의 내용은 다음과 같다.

# /etc/rc.d/init.d/james#!/bin/sh## Startup script for James, the Jakarta Mail Server# chkconfig: 2345 95 15# description: James is a Mail Server# processname: james# pidfile: /var/run/james.pid# config: /opt/james/apps/james/conf/config.xml# logfiles: /opt/james/apps/james/logs## version 1.0 -## Source function library.. /etc/rc.d/init.d/functions#SET THE FOLLOWING LINE TO YOUR JAVA_HOMEexport JAVA_HOME=/usr/local/java#SET THE FOLLOWING LINE TO YOUR CORRECT JBOSS_HOMEexport JAMES_HOME=/usr/local/jamesexport PATH=$PATH:$JAMES_HOME/bin:$JAVA_HOME/bin:$JAVA_HOME/jre/bin#IF YOU NEED SPECIAL CLASSES IN YOUR CLASSPATH#AT STARTUP, ADD THEM TO YOUR CLASSPATH HERE#export CLASSPATH=RETVAL=0# See how we were called.case "$1" in start) cd $JAMES_HOME/bin echo -n "Starting james daemon: " daemon $JAMES_HOME/bin/james_daemon.sh start RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/james ;; stop) echo -n "Stopping james daemon: " killproc james RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/james ;; restart) echo -n "Restarting james daemon: " $0 stop sleep 2 $0 start ;; esac

james의 작성이 끝났으면 실행모드로 바꾸고 /etc/rc.d/rc3.d/와 /etc/rc.d/rc5.d/에 alias를 만든다.

Console # chmod +x jamesConsole # cd /etc/rc.d/rc3.d/Console # ln -s /etc/rc.d/init.d/james S99jamesConsole # cd /etc/rc.d/rc5.d/Console # ln -s /etc/rc.d/init.d/james S99james


 

TEST

Console # ./run.sh Using PHOENIX_HOME: /usr/local/jamesUsing PHOENIX_TMPDIR: /usr/local/james/tempUsing JAVA_HOME: /usr/local/javaRunning Phoenix: Phoenix 4.0.1James 2.1.3Remote Manager Service started plain:4555POP3 Service started plain:110SMTP Service started plain:25NNTP Service started plain:119Fetch POP DisabledJVM exiting abnormally. Shutting down Phoenix. ← CTRL + CConsole # /etc/rc.d/init.d/james start ← daemon script test..Starting james daemon: [ 확인 ]

위와 같이 정상적인 실행이 되었다면, Oracle sqlplus나 JBuilder Database Pilot을 통해 Repository를 확인해보면 MailBox/Spool/User에 대한 정보를 다음과 같이 볼 수 있다.

Console # sqlplus mail/mail@mailSQL*Plus: Release 9.2.0.1.0 - Production on Wed Aug 13 10:28:59 2003Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.Connected to:Oracle9i Enterprise Edition Release 9.2.0.1.0 - ProductionWith the Partitioning, OLAP and Oracle Data Mining optionsJServer Release 9.2.0.1.0 - ProductionSQL> select * from tab;TNAME TABTYPE CLUSTERID------------------------------ ------- ----------DEADLETTER TABLEINBOX TABLESPOOL TABLEUSERS TABLESQL> desc inbox Name Null? Type ----------------------------------------- -------- ---------------------------- MESSAGE_NAME NOT NULL VARCHAR2(200) REPOSITORY_NAME NOT NULL VARCHAR2(255) MESSAGE_STATE NOT NULL VARCHAR2(30) ERROR_MESSAGE VARCHAR2(200) SENDER VARCHAR2(255) RECIPIENTS NOT NULL VARCHAR2(1000) REMOTE_HOST NOT NULL VARCHAR2(100) REMOTE_ADDR NOT NULL VARCHAR2(20) MESSAGE_BODY NOT NULL LONG RAW LAST_UPDATED NOT NULL DATE SQL> desc users; Name Null? Type ----------------------------------------- -------- ---------------------------- USERNAME NOT NULL VARCHAR2(64) PWDHASH VARCHAR2(50) PWDALGORITHM VARCHAR2(20) USEFORWARDING NUMBER(38) FORWARDDESTINATION VARCHAR2(255) USEALIAS NUMBER(38) ALIAS VARCHAR2(255) * 출처: 야옹이 백작 (http://macspace.cnu.ac.kr/%7Earmateras/v3/favorites/Computer/Unix/james.html)
Posted by Tornado tornado

댓글을 달아 주세요