All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mes.james-server-spring-app.3.8.2.source-code.mailetcontainer.xml Maven / Gradle / Ivy

The newest version!
<?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 -->

<!-- This block is responsible for processing messages on the spool. -->

<mailetcontainer enableJmx="true">
 
    <!-- MailAddress used for PostMaster -->
    <context>
        <!-- When the domain part of the postmaster mailAddress is missing, the default domain is appended.
        You can configure it to (for example) <postmaster>[email protected]</postmaster> -->
        <postmaster>postmaster</postmaster>
    </context>

    <!-- Number of spool threads -->
    <spooler>
      <threads>20</threads>
        <errorRepository>file://var/mail/error/</errorRepository>
    </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>3</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>
            -->
          <!-- in case of multiple gateway load balancing can be activated -->
          <!-- with the loadBalancing flag, default is true -->
          <!--
          <loadBalancing>true</loadBalancing>
            -->
          <!-- 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>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy