XMS can easily be setup as an incoming gateway mail server. An incoming gateway mail server sits on the outside of your network (listens on port 25 for your domains), and then directs local mail to a local delivery server (this can be your existing mail server)
It is very important to ensure that your mail server is not running as an open relay. An open relay is a mail server that allows anyone on the internet to send mail through it.
The first thing you want to do is add our Simple Relay Filter to your SMTP Server Service (xms.transport.smtp.SMTPService) in your config.xml file. With this filter only mail to the domain list, will be allowed through. You can also specify a list of IP addresses that are allowed to relay mail (IP's local to your network perhaps) using the allow attribute, or which ip's to explicitly deny using the deny attribute.
<service class="xms.transport.smtp.SMTPService"
name="smtpserver" target="spool" port="25" address="*" hostname="mail.yourcompany.com">
<filter class="xms.filter.recipient.SimpleRelayFilter"
domains="yourcompany.com,mail.yourcompany.com,[12.34.56.78]"
allow="10.0.0.*,176.16.0.*,127.0.0.1" />
<!-- other SMTP filters here -->
</service>
You only need to add the filter tag, the service tag for the SMTPService should already be in your config.xml file.
![]() | Note |
|---|---|
| If you have a large number of domains hosted on your email server you may want to use the List Relay Filter (xms.filter.recipient.ListRelayFilter) instead of the SimpleRelayFilter. The List Relay filter allows you to use a List, which can be generated from a database, or a file, or potentially any other source you have. | |
![]() | Note |
|---|---|
| By default XMS uses a ConnectionFilter to ensure that the server is not setup as an open relay. The filter is configured to only allow connections from localhost. You will need to remove or reconfigure this filter to use your server as an email gateway. | |
You may want to explicitly reject certain user that you may not be using such as webmaster, info. You also may want to set a list of user names that are valid, and reject all others. This is done with the Recipient List Filter. The userlist attribute of the filter is the name of a list registered in the String List Service.
Here's some example configuration xml for your config.xml file.
<service class="xms.transport.smtp.SMTPService"
name="smtpserver" target="spool" port="25" address="*" hostname="mail.yourcompany.com">
<filter class="xms.filter.recipient.SimpleRelayFilter"
domains="yourcompany.com,mail.yourcompany.com,[12.34.56.78]"
allow="10.0.0.*,176.16.0.*,127.0.0.1" />
<filter class="xms.filter.recipient.RecipientListFilter"
userlist="myuserlist" action="reject" mode="exclusive"
domain="*" />
<!-- other SMTP filters here -->
</service>
<!-- other services -->
<service class="xms.dataservices.list.XMSStringListService">
<list class="xms.dataservices.list.PropertyFileStringList"
name="myuserlist" cache="true" cachetimeout="0"
path="./conf/yourcompany.com.users" />
</service>
We used the * wildcard for the domain attribute, but if you have multiple domains you can setup lists for each one.
![]() | Note |
|---|---|
| Note that the order of filters in your config.xml matters. You should order the filters in the order you would like them to be executed. So in this example we run the relay filter first to check the domain, then we check the username. | |
The filter references the myuserlist list, which has a list stored in a file. The contents of the file may look like this:
hostmaster=* abuse=* security=* postmaster=* pete=* bob=* matt=* greg=* gary=* rob=*
You can use the SMTP Client Service to redirect mail to a local delivery SMTP server. This is done simply by adding a target attribute to your SMTP Client Service tag in config.xml.
<service class="xms.transport.smtp.SMTPClientService" name="smtpclient" target="127.0.0.1:10025" />
This redirects any mail that makes it through the gateway to port 10025 on 127.0.0.1 or localhost.
![]() | Note |
|---|---|
| The service tag for the SMTP Client Service, should already be in your config.xml file. You just need to add the target attribute. | |