James安装及使用案例-Linux

一、安装

环境:linux-centos7.6

1. 安装JDK(前置)

yum search java-11-openjdk
yum install -y java-11-openjdk
which java

lrwxrwxrwx. 1 root root 22 10月 29 23:27 /usr/bin/java -> /etc/alternatives/java

ls -lrt /etc/alternatives/java

lrwxrwxrwx. 1 root root 62 10月 29 23:27 /etc/alternatives/java -> /usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el7_8.x86_64/bin/java

修改etc/profile,配置环境变量,黄色部分即为JDK位置

2. 安装James

下载:
wget https://www.apache.org/dyn/closer.lua/james/server/james-server-app-3.1.0-app.zip https://downloads.apache.org/james/server/3.5.0/james-server-app-3.5.0-app.zip
解压:
uzip

二、配置

1. 配置Domain

  1. 修改/config/domainlist.xml
<?xml version="1.0"?>

<!-- JPA implementation for DomainList -->
<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
   <autodetect>false</autodetect>
   <autodetectIP>false</autodetectIP>
   <defaultDomain>develop.com</defaultDomain>
   <domainnames>
       <domainname>develop1.com</domainname>
	   <domainname>develop2.com</domainname>
   </domainnames>
</domainlist>

<!-- XML based implementation for DomainList -->
<!--<domainlist class="org.apache.james.domainlist.xml.XMLDomainList">
</domainlist> -->

  1. 将你自定义的域名加入到 /etc/hosts中

2. 将默认的DERBY存储改为Mysql存储

  1. 将驱动 jar 包(如:mysql-connector-java-8.0.22.jar)添加到 conf/lib 下。
    下载:wget https://jorian-space-01.oss-cn-beijing.aliyuncs.com/mysql-connector-java-8.0.22.jar
  2. 修改conf/james-database.properties ,注释掉 默认的 DERBY 存储,改为使用 mysql,记得创建表,否则启动时会报错找不到表

## Use derby as default
#database.driverClassName=org.apache.derby.jdbc.EmbeddedDriver
#database.url=jdbc:derby:../var/store/derby;create=true
#database.username=app
#database.password=app

#use mysql store
database.driverClassName=com.mysql.jdbc.Driver
database.url=jdbc:mysql://192.168.1.140:3306/james?rewriteBatchedStatements=true&useUnicode=true&characterEncoding=utf8
database.username=root
database.password=root

# Supported adapters are:
# DB2, DERBY, H2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE 
vendorAdapter.database=MYSQL

# Use streaming for Blobs
# This is only supported on a limited set of databases atm. You should check if its supported by your DB before enable
# it. 
# 
# See:
# http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html  #7.11.  LOB Streaming 
# 
openjpa.streaming=false

# Validate the data source before using it
# datasource.testOnBorrow=true
# datasource.validationQueryTimeoutSec=2
# This is different per database. See https://stackoverflow.com/questions/10684244/dbcp-validationquery-for-different-databases#10684260
datasource.validationQuery=select 1

  1. 修改mailetcontainer.xml,
    postmaster 修改为管理员邮箱,可以为 postmaster@yourDomain
    在这里插入图片描述

  2. repositoryPath 同时存在文件存储 (file://)、数据库存储 (db://) 的,将默认的文件存储注释掉,并释放数据库存储;对于只存在文件存储的,不进行释放
    在这里插入图片描述

  3. RemoteAddrNotInNetwork 所在节点注释掉
    在这里插入图片描述
    完整配置如下:

<?xml version="1.0"?>

<mailetcontainer enableJmx="true">
 
    <!-- MailAddress used for PostMaster -->
    <context>
        <postmaster>postmaster@develop.com</postmaster>
    </context>

    <!-- Number of spool threads -->
    <spooler>
      <threads>20</threads>
    </spooler>
      
  <processors>
  
    <!-- 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 state="root" enableJmx="true">

       <!-- This mailet redirects mail for the user 'postmaster' at any local domain to -->
       <!-- the postmaster address specified for the server. The postmaster address -->
       <!-- is required by rfc822. Do not remove this mailet unless you are meeting -->
       <!-- this requirement through other means  -->
       <mailet match="All" class="PostmasterAlias"/>

       <!-- Important check to avoid looping -->
       <mailet match="RelayLimit=30" class="Null"/>

        <!-- The WithPriority mailet allows to set a priority attribute on the mail. If the
             attribute is set and priority handling is enabled it will take care of moving the
             Mails with higher priority to the head of the queue (so the mails are faster handled). -->
        <!--
        <mailet match="All" class="WithPriority">
            <priority>8</priority>
        </mailet>
        -->
        <!-- Using the following three matchers you can control the mail processing flow based
             on the priority attribute. Note that if a mail's priority is set to 8, then all of
             the below will match. -->
        <!--
        <mailet match="HasPriority=8" class="Null"/>
        <mailet match="AtLeastPriority=8" class="Null"/>
        <mailet match="AtMostPriority=8" class="Null"/>
        -->

        <!-- Check attachment extensions for possible viruses -->
       <!-- The "-z" option requests the check to be non-recursively applied -->
       <!-- to the contents of any attached '*.zip' file. -->
       <!-- 
       <mailet match="AttachmentFileNameIs=-d -z *.exe *.com *.bat *.cmd *.pif *.scr *.vbs *.avi *.mp3 *.mpeg *.shs" class="Bounce" onMatchException="error">
          <inline>heads</inline>
          <attachment>none</attachment>
          <passThrough>false</passThrough>
          <prefix>[REJECTED]</prefix>
          <notice>
The Security Policy of XXX does not allow to forward messages containing attachments having any of the extensions .exe, .com, .bat, .cmd, .pif, .scr, .vbs, .avi, .mp3, .mpeg, .shs, therefore your message has been rejected.

Please don't reply to this e-mail as it has been automatically sent by the antivirus system.

Regards, Postmaster XXX.YYY
.....................................
          </notice>
       </mailet>
         -->

       <!-- sample SMIME mailets configuration -->
       <!-- 
       <mailet match="IsSMIMEEncrypted" class="SMIMEDecrypt">
          <keyStoreType>pkcs12</keyStoreType>
          <keyStoreFileName>c:/path.pfx</keyStoreFileName>
          <keyStorePassword>myKeyStorePass</keyStorePassword>
          <keyAlias>myKeyAlias</keyAlias>
          <keyAliasPassword>myKeyPass</keyAliasPassword>
       </mailet>
         
       <mailet match="IsSMIMESigned" class="SMIMECheckSignature">
          <keyStoreType>pkcs12</keyStoreType>
          <keyStoreFileName>c:/path.pfx</keyStoreFileName>
          <keyStorePassword>myKeyStorePass</keyStorePassword>
          <strip>false</strip>
          <onlyTrusted>true</onlyTrusted>
       </mailet>
         -->


       <!-- Anti-spam processing -->
       <!-- The following two entries avoid double anti-spam analysis -->
       <!-- for forwarded messages. -->
       <!-- Has spam checking already been done? -->
       <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
          <processor>transport</processor>
       </mailet>
       <!-- Spam checking will not be done twice -->
       <mailet match="All" class="SetMailAttribute">
          <spamChecked>true</spamChecked>
       </mailet>

       <!-- 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.
         -->

       <!-- Messages from authenticated senders never are spam -->
       <mailet match="SMTPAuthSuccessful" class="ToProcessor">
          <processor>transport</processor>
       </mailet>

       <!-- Messages signed by trusted users never are spam -->
       <!-- Uncommenting the following entry, messages with valid signatures will never be considered spam. -->
       <!-- This can be a valid policy *if* SMIMECheckSignature was invoked -->
       <!-- with<onlyTrusted>true</onlyTrusted>set -->
       <!--
       <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="ToProcessor">
          <processor>transport</processor>
       </mailet>
         -->

       <!-- specific known senders -->
       <!--
       <mailet match="SenderIs=goodboy@goodhost"
                 class="ToProcessor">
          <processor>transport</processor>
       </mailet>
         -->

       <!-- End of White List -->

       <!-- Sample matching to kill a message (send to Null) -->
       <!--
       <mailet match="RecipientIs=badboy@badhost" class="Null"/>
         -->
        <!--
       <mailet match="CompareNumericHeaderValue=X-MessageIsSpamProbability >0.90" class="SetMailAttribute" onMatchException="noMatch">
          <isSpam>true</isSpam>
       </mailet>

       <mailet match="CompareNumericHeaderValue=X-MessageIsSpamProbability >0.90" class="SetMimeHeader" onMatchException="noMatch">
          <name>X-MessageIsSpam</name>
          <value>true</value>
       </mailet>

       <mailet match="CompareNumericHeaderValue=X-MessageIsSpamProbability >0.99" class="ToProcessor" onMatchException="noMatch">
          <processor>spam</processor>
          <notice>Spam not accepted</notice>
       </mailet>
         -->

       <!-- 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 state="error" enableJmx="true">
       <!-- If you want to notify the sender their message generated an error, uncomment this       -->
       <!--
       <mailet match="All" class="Bounce"/>
         -->
       <!-- If you want to notify the postmaster that a message generated an error, uncomment this  -->
       <!--
       <mailet match="All" class="NotifyPostmaster"/>
         -->

       <!-- 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>

       </mailet>
    </processor>

    <!-- Processor CONFIGURATION SAMPLE: transport is a sample custom processor for local or -->
    <!-- remote delivery -->
    <processor state="transport" enableJmx="true">

      <!-- This is an example configuration including configuration for a list server. -->
      <!-- CHECKME: before uncommenting this, edit the configuration file's contents   -->
      <!--
          &listserverConfig;
        -->

       <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
          <name>X-UserIsAuth</name>
          <value>true</value>
          <onMailetException>ignore</onMailetException>
       </mailet>
    
       <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
          <name>X-WasSigned</name>
          <value>true</value>
          <onMailetException>ignore</onMailetException>
       </mailet>

       <!-- Add a server-side signature -->
       <!--
       <mailet match="All" class="SMIMESign" onMailetException="ignore">
          <keyStoreType>jks</keyStoreType>
          <keyStoreFileName>path.keystore</keyStoreFileName>
          <keyStorePassword>myKeyStorePass</keyStorePassword>
          <keyAlias>myKeyAlias</keyAlias>
          <keyAliasPassword>myKeyPass</keyAliasPassword>
          <signerName>XXX Trusted Server</signerName>
          <rebuildFrom>true</rebuildFrom>
          <postmasterSigns>true</postmasterSigns>
          <debug>true</debug>
       </mailet>
         -->

       <!-- Experimental quota Matcher -->
       <!-- Check if over quota -->
       <!--

       <mailet match="IsOverQuota" class="ToProcessor">
          <processor>over-quota</processor>
        </mailet>
         -->
       <!--  The RecipientRewriteTable will use the definitions found in recipientrewritetablexml -->
         <mailet match="All" class="RecipientRewriteTable" />

         <!-- Place a copy in the user Sent folder -->
         <mailet match="SenderIsLocal" class="ToSenderFolder">
           <folder>Sent</folder>
           <consume>false</consume>
         </mailet>

       <!-- Is the recipient is for a local account, deliver it locally -->
       <mailet match="RecipientIsLocal" class="Sieve"/>
       <mailet match="RecipientIsLocal" class="AddDeliveredToHeader"/>
       <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>local-address-error</processor>
          <notice>550 - Requested action not taken: no such user here</notice>
       </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. See also<authorizedAddresses>in SMTP Server -->
       <!-- -->
       <!-- 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>relay-denied</processor>
          <notice>550 - Requested action not taken: relaying denied</notice>
       </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>outgoing</outgoing>

          <!-- Delivery Schedule based upon RFC 2821, 4.5.4.1 -->
          <!-- 5 day retry period, with 4 attempts in the first
                 hour, two more within the first 6 hours, and then
                 every 6 hours for the rest of the period.
          <delayTime>4 * 15 minutes, 2 * 3 hours, 18 * 6 hours</delayTime>
          -->
          <delayTime>5000, 100000, 500000</delayTime>
          <maxRetries>25</maxRetries>
            
          <!-- The max reties which will used if no A or MX record for the domain was found. -->
          <!-- If 0 it will fail on first time -->
          <maxDnsProblemRetries>0</maxDnsProblemRetries>

          <!-- The number of threads that should be trying to deliver outgoing messages -->
          <deliveryThreads>10</deliveryThreads>

          <!-- If false the message will not be sent to given server if any recipients fail -->
          <sendpartial>true</sendpartial>
            
          <!-- By default we send bounces to the "bounce" processor -->
          <!-- By removing this configuration James will fallback to hardcoded bounce -->
          <!-- notifications -->
          <bounceProcessor>bounces</bounceProcessor>

          <!-- 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. -->
          <!-- Although normally multiple addresses are implemented through proper -->
          <!-- DNS configuration, the RemoteDelivery mail does allow specifying -->
          <!-- multiple gateway elements, each of which may also have a port -->
          <!-- e.g., mygateway:2525 -->
          <!-- the gatewayPort element is used as a default -->
          <!--
          <gateway>otherserver.mydomain.com</gateway>
          <gatewayPort>25</gatewayPort>
            -->
          <!-- If the gateway requires smtp authentication the following directives -->
          <!-- (gatewayUsername/gatewayPassword) can be used. -->
          <!--
          <gatewayUsername>login</gatewayUsername>
          <gatewayPassword>pass</gatewayPassword>
            -->
            
          <!-- Set the HELO/EHLO name to use when connectiong to remote SMTP-Server -->
          <!--
          <mail.smtp.localhost>myMailServer</mail.smtp.localhost>
            -->
       </mailet>

    </processor>

    <processor state="over-quota" enableJmx="true">
      <mailet match="All" class="MetricsMailet">
        <metricName>mailet-over-quota-error</metricName>
      </mailet>
      <mailet match="All" class="Bounce">
        <message>The following recipients do not have enough space for storing the email you sent them.</message>
        <attachment>none</attachment>
      </mailet>
      <mailet match="All" class="ToRepository">
        <repositoryPath>file://var/mail/over-quota-error/</repositoryPath>
      </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 state="spam" enableJmx="true">
     
       <!-- To place the spam messages in the user junk folder, uncomment this matcher/mailet configuration -->
       <!--
       <mailet match="RecipientIsLocal" class="ToRecipientFolder">
           <folder>Junk</folder>
           <consume>false</consume>
       </mailet>
        -->

       <!-- 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="Bounce"/>
         -->

       <!-- 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>

    <!-- messages containing viruses. -->
    <processor state="virus" enableJmx="true">
      
       <!-- To avoid a loop while bouncing -->
       <mailet match="All" class="SetMailAttribute">
          <org.apache.james.infected>true, bouncing</org.apache.james.infected>
       </mailet>

       <!-- If the sender is authenticated, notify the infection -->
       <mailet match="SMTPAuthSuccessful" class="Bounce">
          <inline>heads</inline>
          <attachment>none</attachment>
          <notice>Warning: We were unable to deliver the message below because it was found infected by virus(es).</notice>
       </mailet>

       <!-- In any other situation ghost it, -->
       <!-- as viruses almost always spoof the sender's address -->
       <mailet match="All" class="Null" />
    </processor>

    <!-- This processor handles messages that are for local domains, where the user is unknown -->
    <processor state="local-address-error" enableJmx="true">
       <!-- To avoid bouncing/archiving spam, uncomment this matcher/mailet configuration -->
       <!--
       <mailet match="HasMailAttribute=isSpam" class="Null" onMatchException="noMatch"/>
         -->

       <!-- To notify the sender the address was invalid, uncomment this matcher/mailet configuration -->
       <!-- The original message is not attached to keep the bounce processor from deliverying spam -->
       <!--
       <mailet match="All" class="Bounce">
          <attachment>none</attachment>
       </mailet>
         -->

       <!-- To notify the postmaster that a message had an invalid address, uncomment this matcher/mailet configuration -->
       <!--
       <mailet match="All" class="NotifyPostmaster"/>
         -->

       <mailet match="All" class="ToRepository">
          <!--<repositoryPath>file://var/mail/address-error/</repositoryPath> -->
          <!-- An alternative database repository example follows. -->
          
          <repositoryPath>db://maildb/deadletter/address-error</repositoryPath>
           
       </mailet>
    </processor>

    <!-- This processor handles messages that are for foreign domains, where relaying is denied -->
    <!-- As of James v2.2, this processor can be deprecated by using the<authorizedAddresses>tag
           in the SMTP Server, and rejecting the message in the protocol transaction.  -->
    <processor state="relay-denied" enableJmx="true">
       <!-- To notify the sender the address was invalid, uncomment this matcher/mailet configuration -->
       <!-- The original message is not attached to keep the bounce processor from deliverying spam -->
       <!--
       <mailet match="All" class="Bounce">
          <attachment>none</attachment>
       </mailet>
         -->

       <!-- To notify the postmaster that a relay request was denied, uncomment this matcher/mailet configuration -->
       <!--
       <mailet match="All" class="NotifyPostmaster"/>
         -->

       <mailet match="All" class="ToRepository">
         <!-- <repositoryPath>file://var/mail/relay-denied/</repositoryPath>-->
          <!-- An alternative database repository example follows. -->
          
          <repositoryPath>db://maildb/deadletter/relay-denied</repositoryPath>
            
       </mailet>
    </processor>

    <!-- This processor handle the bounces from RemoteDelivery: As of James v2.3, this is the new -->
    <!-- Default. -->
    <!-- -->
    <!-- DSNBounce properly create a DSN compliant bounce -->
    <processor state="bounces" enableJmx="true">
       <mailet match="All" class="DSNBounce">
          <passThrough>false</passThrough>

          <!-- optional subject prefix prepended to the original message -->
          <!--
          <prefix>[bounce]</prefix>
            -->
            
          <!-- message, heads or none, default=message -->
          <!--
          <attachment>heads</attachment>
            -->
            
          <!-- the message sent in the bounce, the first occurrence of the pattern [machine] is -->
          <!-- replaced with the name of the executing machine -->
          <!-- Default: Hi. This is the James mail server at [machine] ... -->
          <!--
          <messageString>Here is [machine]. I'm not able to deliver this message.</messageString>
            -->
        </mailet>
    </processor>

  </processors>

</mailetcontainer>

3. 启用SMTP认证

  1. 修改 vi conf/smtpserver.xml,
    第一个 helloname 节点修改为邮箱后缀 [域名] -> 降低发送的邮件被 (收件方邮件服务器) 扔到垃圾箱的几率,
    authRequired、verifyIdentity设置为 true 能够防止此邮件服务被当做邮件中继服务,防止跨账号邮件行为,避免被域名信誉机构拉入黑名单,影响或无法正常发送邮件。
    完整配置如下:
<?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.                                           
 -->
 
<!--
   This template file can be used as example for James Server configuration
   DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
-->
 
<!-- See http://james.apache.org/server/3/config.html for usage -->

<smtpservers>

   <!-- 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">

     <jmxName>smtpserver</jmxName>

     <!-- Configure this to bind to a specific inetaddress -->
     <!-- Please NOTE: you should add this IP also to your RemoteAddrNotInNetwork -->
     <!-- in order to avoid relay check for locallly generated bounces -->
     <!-- 
            Port 25 is the well-known/IANA registered port for SMTP. 
            Port 465 is the well-known/IANA registered port for SMTP over TLS.
            -->
     <bind>0.0.0.0:25</bind>

     <connectionBacklog>200</connectionBacklog>

     <!-- Set to true to support STARTTLS or TLS for the Socket.
           To use this you need to copy sunjce_provider.jar to /path/james/lib directory.
      -->
     <tls socketTLS="false" startTLS="false">
       <!-- To create a new keystore execute:
        keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
         -->
       <keystore>file://conf/keystore</keystore>
       <secret>yoursecret</secret>
       <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
       <!-- The algorithm is optional and only needs to be specified when using something other
        than the Sun JCE provider - You could use IbmX509 with IBM Java runtime. -->
       <algorithm>SunX509</algorithm>
     </tls>
      
        <!-- 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">develop.com</helloName>
         
         
        <!-- connection timeout in secconds -->
        <connectiontimeout>360</connectiontimeout>

        <!-- Set the maximum simultaneous incoming connections for this service -->
        <connectionLimit>100</connectionLimit>
         
        <!-- Set the maximum simultaneous incoming connections per IP for this service -->
        <connectionLimitPerIP>100</connectionLimitPerIP>
         
        <!--  Uncomment this if you want to require SMTP authentication.

               supported values:
               true: required but announced only to not authorizedAddresses
               false: don't use AUTH
               announce: like true, but always announce AUTH capability to clients

               The correct behaviour per RFC value would be false or announce
               but we still support true for backward compatibility and because
               some webmail client fails when AUTH is announced but no authentication
               information has been provided
          -->
        <authRequired>true</authRequired>


<!-- CHECKME! -->
        <!--  Uncomment this if you want to authorize specific addresses/networks.
               If you use SMTP AUTH, addresses that match those specified here will
               be permitted to relay without SMTP AUTH.  If you do not use SMTP
               AUTH, and you specify addreses here, then only addresses that match
               those specified will be permitted to relay.

               Addresses may be specified as a an IP address or domain name, with an
               optional netmask, e.g.,

               127.*, 127.0.0.0/8, 127.0.0.0/255.0.0.0, and localhost/8 are all the same

               See also the RemoteAddrNotInNetwork matcher in the transport processor.
               You would generally use one OR the other approach.
         -->
        <authorizedAddresses>127.0.0.0/8</authorizedAddresses>

        <!--  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 -->
        <!--  If unspecified, default value is true -->

        <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>
         
        <!--  This sets wether to enforce the use of HELO/EHLO salutation before a -->
        <!--  MAIL command is accepted. If unspecified, the value defaults to true -->
        <!-- 
        <heloEhloEnforcement>true</heloEhloEnforcement>
         -->
         
        <!-- WARNING: This is Non-RFC compliant (default value: true) -->
        <!-- See: http://wiki.apache.org/james/StandardsComplianceStatement -->
        <!-- TODO: CHANGE TO OFFICIAL URL LATER -->
        <addressBracketsEnforcement>true</addressBracketsEnforcement>
         
        <!-- This sets the SMTPGreeting which will be used when connect to the smtpserver -->
        <!-- If none is specified a default is generated -->
        <!--
        <smtpGreeting>JAMES SMTP Server</smtpGreeting>
         -->
         
        <!-- The configuration handler chain -->
        <handlerchain>

            <!-- This connect handler can be used to enable POP3 before SMTP support -->
            <!-- Plz note that only the ip get stored to indentify an authenticated client -->
            <!-- The expireTime is the time after which an ipAddress is handled as expired -->
            <!--
            <handler class="org.apache.james.smtpserver.POP3BeforeSMTPHandler">
                <expireTime>1 hour</expireTime>
            </handler>
             -->
            
            <!-- This command handler check against RBL-Lists -->
            <!-- If getDetail is set to true it try to retrieve information from TXT Record -->
            <!-- why the ip was blocked. Default to false -->           
            <!-- STOP - before you uncomment out the DNS RBL handler,
                  please take a moment to review each block list.  We
                  have included some that various JAMES committers use,
                  but you must decide which, if any, are appropriate
                  for your environment.  The mail servers hosting
                  @apache.org mailing lists, for example, use a
                  slightly different list than we have included below.
                  And it is likely that most JAMES committes also have
                  slightly different sets of lists.  The SpamAssassin
                  user's list would be one good place to discuss the
                  measured quality of various block lists.

                  NOTA BENE: the domain names, below, are terminated
                  with '.' to ensure that they are absolute names in
                  DNS lookups.  Under some circumstances, names that
                  are not explicitly absolute could be treated as
                  relative names, leading to incorrect results.  This
                  has been observed on *nix and MS-Windows platforms
                  by users of multiple mail servers, and is not JAMES
                  specific.  If you are unsure what this means for you,
                  please speak with your local system/network admins.
              -->
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.DNSRBLHandler">
                <getDetail>false</getDetail>
                <rblservers>
                    <whitelist>query.bondedsender.org.</whitelist>
                    <blacklist>sbl-xbl.spamhaus.org.</blacklist>
                    <blacklist>dul.dnsbl.sorbs.net.</blacklist>
                    <blacklist>list.dsbl.org.</blacklist>
                </rblservers>
            </handler>           
             -->
     
            <!-- This command handler can be used to reject emails with not match the SPF record of the sender domain -->
            <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
            <!-- are allowed to relay. Default is false. --> 
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.SPFHandler">
                <blockSoftFail>false</blockSoftFail>
                <blockPermError>true</blockPermError>
            </handler>
             -->   
                 
            <!-- checks for resolvable HELO/EHLO before accept the HELO/EHLO -->
            <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
            <!-- are allowed to relay. Default is false. -->
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.ResolvableEhloHeloHandler"/>
             -->
            
            <!-- Checks HELO/EHLO is equal the reverse of the connecting client before accept it -->
            <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
            <!-- are allowed to relay. Default is false. -->
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.ReverseEqualsEhloHeloHandler"/>
             -->
            
            <!-- If activated mail is only accepted if the sender contains -->
            <!-- a resolvable domain having a valid MX Record or A Record associated! -->
            <!-- If checkAuthNetworks is set to true sender domain will be checked also for clients that -->
            <!-- are allowed to relay. Default is false. -->
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.ValidSenderDomainHandler"/>
             -->
         
            <!-- With ValidRcptHandler, all email will get rejected which has no valid user -->
            <!-- You need to add the recipient to the validRecipient list if you want -->
            <!-- to accept email for a recipient which not exist on the server -->
            <!-- If you want James to act as a spamtrap or honeypot, you may comment ValidRcptHandler -->
            <!-- and implement the needed processors in spoolmanager.xml -->
            <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
            
            <!-- If activated you can limit the maximal recipients -->
            <!-- 
            <handler class="org.apache.james.smtpserver.fastfail.MaxRcptHandler">
                <maxRcpt>10</maxRcpt>               
            </handler>
             -->
            
            <!-- If uncomment this block you can enable greylisting. For more infos-->
            <!-- how greylisting work see: http://projects.puremagic.com/greylisting/whitepaper.html -->
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.JDBCGreylistHandler">
                <repositoryPath>db://maildb</repositoryPath>
                <sqlFile>file://conf/sqlResources.xml</sqlFile>
                <tempBlockTime>1 hour</tempBlockTime>
                <unseenLifeTime>4 hours</unseenLifeTime>
                <autoWhiteListLifeTime>36 days</autoWhiteListLifeTime>
                <whitelistedNetworks>127.0.0.0/8</whitelistedNetworks>
            </handler>
             -->
     
            <!-- Load the core command handlers -->
            <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>       
           
            <!-- This handler can add a hint to the mail which tells the MailQueue which email should get processed first -->
            <!-- Normally the MailQueue will just handles Mails in FIFO manner -->
            <!-- Valid priority values are 1,5,9 where 9 is the highest-->
            <!-- 
            <handler class="org.apache.james.smtpserver.MailPriorityHandler">
                <priorityEntries>
                    <priorityEntry>
                        <domain>yourdomain1</domain>
                        <priority>1</priority>
                    </priorityEntry>
                    <priorityEntry>
                        <domain>yourdomain2</domain>
                        <priority>9</priority>
                    </priorityEntry>
                <priorityEntries>
            </handler>
             -->
             
            <!-- This MessageHandler could be used to check message against spamd before -->
            <!-- accept the email. So its possible to reject a message on smtplevel if a -->
            <!-- configured hits amount is reached. -->
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.SpamAssassinHandler">
                <spamdHost>127.0.0.1</spamdHost>
                <spamdPort>783</spamdPort>
                <spamdRejectionHits>10</spamdRejectionHits>
            </handler>
             -->
     
            <!-- This MessageHandler could be used to extract domain out of the message and check -->
            <!-- this domains against uriRbllists. See http://www.surbl.org for more information. -->
            <!-- The message get rejected if a domain matched . -->
            <!--
            <handler class="org.apache.james.smtpserver.fastfail.URIRBLHandler">
                <action>reject</action>
                <getDetail>true</getDetail>
                <uriRblServers>
                    <server>multi.surbl.org</server>
                </uriRblServers>
            </handler>    
             -->
            <!-- 
            <handler class="org.apache.james.smtpserver.SetMimeHeaderHandler">
                <headername>SPF-test</headername>
                <headervalue>passed</headervalue>
            </handler>
             -->
        </handlerchain>           
  
   </smtpserver>

</smtpservers>


三、启动

配置完毕启动:

sh ./run.sh

后台启动:

nohup sh ./run.sh & >james.log

四、使用thunderbird测试

  1. 下载并安装thunderbird: https://www.thunderbird.net/en-US/.

  2. 配置
    __mindmap__topiccreate  a new account

  3. 可以在更改相关配置
    在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值