< XMail Server > Version : 1.9

Project type

Last update

Author

 

Credits

 

 

 

 Gnu Public License

 15-06-2002

 Davide Libenzi

 

 Michael Hartle
 Shawn Anderson
 Dick van der Kaaden
 Eric Sanders

http://www.gnu.org 

http://www.xmailserver.org
davidel@xmailserver.org 

 

mhartle@hartle-klug.com
sanderson@eye-catcher.com
dick@netrex.nl
eric.sanders@twd-industries.com

Warning

 

If you are upgrading from an existing version of XMail it is strongly suggested that you read the ChangeLog.txt file to check for important modifications that can change the way XMail works.

Quick Start    0§8^°)

 

If you want to run XMail without reading the whole manual then go to chapter "Part 7 - Configuration".

Part 0 - License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

Part 1 - Overview

This server is born because I needed a free and stable Mail Server for my old company, which was using a Windows network. I don't like to reinvent the wheel but the need of some features pushed me to start a new project. If I could have used a Linux server on my network, I would probably have not had to write any code, but this was not my case. I needed it to be portable. XMail runs on Windows NT/2000/XP and on the following Unix versions: Linux, Solaris and FreeBSD

 

Another reason that drove me to write XMail is the presence of the same tedious steps when setting up a typical mail server, ie: sendmail + qpopper + fetchmail if one needs SMTP, POP3 and external synchronization, or: sendmail + qpopper for only SMTP and POP3 (I've quoted sendmail, qpopper and fetchmail, but there are many other packages You can use to fulfill those needs). With XMail you get an all-in-one package with a central administration that can simplify the above common steps.

 

The first version of XMail Server was created on Windows NT and Linux, and now, FreeBSD and Solaris versions are available. The supported compilers are gcc for Linux, FreeBSD and Solaris and M$ Visual C++ for Windows NT/2000/XP.

Part 2 - Features
 
1. ESMTP server
2. POP3 server
3. Finger server
4. Multiple domains
5. Users don't need a real system account
6. SMTP relay checking
7. SMTP RBL maps check (rbl.maps.vix.com)
8. SMTP RSS maps check (relays.mail-abuse.org)
9. SMTP ORBS relay check (relays.orbs.org)
10. SMTP DUL map check (dialups.mail-abuse.org)
11. SMTP protection over spammers (IP based and address based)
12. SMTP authentication (PLAIN, LOGIN, CRAM-MD5, POP3/SMTP, and custom)
13. SMTP ETRN command support
14. POP3 account synchronizer with external POP3 accounts
15. Account aliasing
16. Domain aliasing
17. Mailing lists
18. Custom mail processing
19. Locally generated mail files delivery
20. Remote administration
21. Custom mail exchangers
22. Logging
23. Multi platform
24. Domain message filters
25. Custom (external) POP3 authentication
Part 3 - Platform availability status

Linux and NT/2000/XP ports are stable, while Solaris and FreeBSD ports have not been tested.

Part 4 - Requirements

- Any version of Linux that has glibc

- Windows NT with Winsock's ws2_32.dll (the TCP/IP stack) correctly installed and configured

- A working DNS and gateway to the internet (if You plan to use XMail over the Web)

 

- To compile on Linux you need gcc and glibc

- To compile on Windows you need MS Visual C++ (a project file is provided) or any other working compiler that supports the Win32 SDK

Part 5 - Getting the source code

Always get the source code from the XMail home page to get the latest version:

http://www.xmailserver.org 

 

Use the correct distribution for your system and don't mix Unix files with Windows files -this is one of the most common cause of XMail bad behavior. When You unzip the package you have to check that the MailRoot directory contained inside the package itself is complete (look at the directory tree listed below) because some unzippers do not create empty directories.

Part 6 - Building XMail

There is a Visual C++ project for Windows NT. You have make files for each Unix version:

# make -f Makefile.lnx     (Linux)

# make -f Makefile.slx     (Linux on SPARC)

# make -f Makefile.plx     (Linux on PPC)

# gmake -f Makefile.bsd  (FreeBSD -You need GCC and GMAKE to compile XMail)

# make -f Makefile.sso    (Sun/Solaris on SPARC -You need GCC to compile XMail)

# make -f Makefile.ssx    (Sun/Solaris on Intel -You need GCC to compile)

 

As soon as the project reach a higher maturity I plan to supply a configure script.

 

Under Linux an init.d startup script is supplied (xmail) to allow you to run XMail as a standard rc? daemon. You must put it into /etc/init.d (it depends on which distro You're using) directory and then create K??xmail - S??xmail links into the proper directories.

 

Under Windows NT/2000/XP the XMail executable is a Win32 service by default and if you want to build it as an application instead of as a service then you have to comment the statement "#define SERVICE" in MainWin.cpp.

 

 [ Linux/Solaris/FreeBSD ]

1. Build XMail
2. Log as root
3. Copy the supplied MailRoot directory where You want it resides (I suppose /var)
4. Do a # chmod 700 /var/MailRoot to setup MailRoot directory access rights
5. Strip XMail executables if You want to reduce its sizes (strip filename)
6. Copy XMail executables to /var/MailRoot/bin 
7. If You've inetd installed You must comment out the lines of /etc/inetd.conf that involves SMTP POP3 Finger and restart inetd (kill -HUP...) 
8. Since XMail use syslog to log messages, enable syslogd if it's not running
9.

Setup the SERVER.TAB configuration file after you have read the rest of this documentation

10. Add your users and domains (after you have read the rest of this documentation)
11. Change or comment out (by adding the # chararacter to the begining of a line) the example account in ctrlaccounts.tab. Use a safe username and password
12. Copy the xmail startup script to Your init.d directory (it's location depends on your distro). If you've setup XMail to work in a subdirectory other than /var/MailRoot then you must edit the xmail startup script to customize its boot
13. If you're smart enough you can create your S??xmail and K??xmail links, otherwise you can use a module configuration tool like the one supplied with KDE (ksysv)
14. To start XMail without rebooting you can run (from root): xmail start. Otherwise reboot your machine
15. Setup the file smtprelay.tab (and/or smtp.ipmap.tab if you need) to restrict mail relaying of your server

 

 [ Windows NT/2000/XP ]

1. Build XMail
2. Copy the supplied MailRoot directory where you want it to reside (C:\MailRoot is a good place)
3. Setup the MailRoot directory (and subdirectories and files) permissions to allow access only to System and Administrators. Doing this you can run XMail only if you are an Administrator (Windows services run under the context of the 'System' account)
4.

Copy the XMail executable files to C:\MailRoot\bin

5. Run Regedit.exe and create a new key called 'GNU' located in HKEY_LOCAL_MACHINE\SOFTWARE\ and then another key called 'XMail' located in HKEY_LOCAL_MACHINE\SOFTWARE\GNU
6. Create a new string value named MAIL_ROOT with the value "C:\MailRoot" in HKEY_LOCAL_MACHINE\SOFTWARE\GNU\XMail\
7. Optionally create a new string value named MAIL_CMD_LINE in HKEY_LOCAL_MACHINE\SOFTWARE\GNU\XMail\ to store your command line options (see "Part 19 - Command line" for the command switches you can use here)
8. Open an NT console (a DOS box under Windows)
9. Change the current directory for C:\MailRoot\bin and run:
XMail --install           (the XMail service is installed but requires you to start it manually)
or
XMail --install-auto   (the XMail service is installed and will start automatically at boot time)
10. If you have other services that provide the same functionalities (SMTP, POP3, Finger), then you must stop these services
11. Setup the SERVER.TAB configuration file
12. Add your users and domains
13. Setup the file permissions for the C:\MailRoot directory to grant access only to SYSTEM and Domain Administrators
14. Change or comment out (by adding the '#' character at the beginning of a line) the example account in ctrlaccounts.tab. Use a safe username and password
15. To start XMail go to the ControlPanel -> Services -> XMail server and start the service (you can also only reboot your machine if the service has been setup to start at boot time)
16. Setup the file smtprelay.tab (and/or smtp.ipmap.tab if You need) to restrict mail relaying of your server

 

If you just want to test XMail then setup an environment variable called MAIL_ROOT that point to the XMail Server root directory.

  • Linux:                         export MAIL_ROOT=/var/XMailRoot

  • Windows NT/2000/XP:   set MAIL_ROOT=C:\MailRoot

The Mail root directory contains the following files:

aliases.tab <file>

aliasdomain.tab <file>

domains.tab <file>

dnsroots <file>

extaliases.tab <file>

mailusers.tab <file>

message.id <file>

pop3links.tab <file>

server.tab <file>

smtpgw.tab <file>

smtpfwd.tab <file>

smtprelay.tab <file>

smtpauth.tab <file>

smtpextauth.tab <file>

userdef.tab <file>

ctrlaccounts.tab <file>

spammers.tab <file>

spam-address.tab <file>

pop3.ipmap.tab <file>

smtp.ipmap.tab <file>

ctrl.ipmap.tab <file>

finger.ipmap.tab <file>

And the following sub-directories:

bin <dir>

cmdaliases <dir>

tabindex <dir>

dnscache <dir>

mx <dir>

ns <dir>

custdomains <dir>

filters <dir>

logs <dir>

pop3locks <dir>

pop3linklocks <dir>

pop3links <dir>

spool <dir>

local <dir>

temp <dir>

0 <dir>

0 <dir>

mess <dir>

rsnd <dir>

info <dir>

temp <dir>

slog <dir>

lock <dir>

cust <dir>

froz <dir>

...

...

userauth <dir>

pop3 <dir>

smtp <dir>

domains <dir>

And for each domain "DOMAIN" handled a directory (located under .\domains):

DOMAIN <dir>

userdef.tab <file>

Inside which reside, for each account "ACCOUNT" (under .\domains\ACCOUNT):

ACCOUNT <dir>

user.tab <file>

mlusers.tab <file>       [ mailing list case ]

mailproc.tab <file>      [ optional ]

pop3.ipmap.tab <file> [ optional ]

and

mailbox <dir>

And for each mailbox structure, a Maildir structure:

Maildir <dir>

tmp <dir>

new <dir>

cur <dir>

 

XMail configuration files

TAB files are pure text files (in the sense meant by each OS: lines are terminated by a [NEWLINE]: <CR><LF> for NT and <CR> for Linux) and use the following format:

"value1"[TAB]"value2"[TAB]...[NEWLINE]

 

 
 Those options are optional -XMail will work even if you do not define something here.
 
 Those options are mandatory -you have to define your own settings here.

 

 

[ALIASES.TAB]

"domain"[TAB]"alias"[TAB]"realaccount"[NEWLINE]

Ex:

"home.com" "davidel" "dlibenzi"

defines "davidel" as alias for "dlibenzi" in the "home.com" domain.

 

"home.com" "foo*bog" "homer@internal-domain.org"

defines an alias for all users whose name starts with 'foo' and ends with 'bog' that points to the locally handled account homer@internal-domain.org.

 

"home.com" "??trips" "travels"

defines an alias for all users whose name starts with two undefined characters and ends with 'trips'.

 

You can have wildcards even in the domain field, like in the following:

"*" "postmaster" "postmaster@domain.net"

 

Note: You __CANNOT__ edit this file while XMail is running due to the fact that is an indexed file.

 

 

[ALIASDOMAIN.TAB]

"aliasdomain"[TAB]"realdomain"[NEWLINE]   where aliasdomain can use wildcards:

"simpson.org" "simpson.com"

"*.homer.net" "homer.net"

The first line defines 'simpson.org' as an alias for 'simpson.com' while the second maps all sub-domains of homer.net to homer.net

 

Note: You __CANNOT__ edit this file while XMail is running due to the fact that is an indexed file.

 

 

[DOMAINS.TAB]

"domain"[NEWLINE]

Ex:

"mydomain.com"

"yourdomain.com"

Defines the domain(s) handled by the XMail server.

 

 

[DNSROOTS]

This is a file that lists a root name server in each line (this is not a TAB file).

This can be created from a query via nslookup for type=ns and host = "."

 

Note: Do not edit this file.

 

 

[EXTALIASES.TAB]

"external-domain"[TAB]"external-account"[TAB]"local-domain"[TAB]"local-user"[NEWLINE]

Ex:

"xmailserver.org" "dlibenzi" "home.bogus" "dlibenzi"

This file is used in configurations in which the server does not run directly on the Internet (like in my case) but acts as an internal mail exchanger and external mail gateway.

This file defines "Return-Path: <...>" mapping for internal mail delivery.

 

If you are using a Mail client like Outlook, Eudora, KMail ... and you have configured your email address with the external account (say "dlibenzi@xmailserver.org") then when you post an internal message to "foo@home.bogus" then the mail client puts your external email address ("dlibenzi@xmailserver.org") in the "MAIL FROM: <...>" SMTP request.

 

Now if the user "foo" replies to this message, he will reply to "dlibenzi@xmailserver.org" and the message will be sent to the external mail server.

With the entry above in the EXTALIASES.TAB file the "Return-Path: <...>" field is filled with "dlibenzi@home.bogus" that leads to an internal mail reply.

 

Note: You __CANNOT__ edit this file while XMail is running due to the fact that is an indexed file.

 

 

[MAILUSERS.TAB]

"domain"[TAB]"account"[TAB]"enc-passwd"[TAB]"account-id"[TAB]"account-dir"[TAB]"account-type"[NEWLINE]

Ex:

"home.bogus" "dlibenzi" "XYZ12EDS..." 1 "dlibenzi" "U"

Defines the account "dlibenzi" for the domain "home.bogus" with the encrypted password "XYZ...", user id "1" and mail directory "dlibenzi" under

$MAIL_ROOT/domains/home.bogus.

 

Note: To allow multiple domains handling the POP3 client must use the entire email address for the POP3 user account (Ex: user@domain not just 'user' as the POP3 account login).

 

The directory "account-dir" __must__ case match with the field "account-dir" of this file.

Note that user id __must__ be unique for all users (duplicated user ids can't exist).

The user id 0 is reserved by XMail and cannot be used.

The last field "U" is the account type:

"U" = User account

"M" = Mailing list account

The encrypted password is generated by XMCrypt which source code is in the XMCrypt.cpp file.

Even if external authentication is used (see "Part 8 - External Authentication") this file _must_ contain an entry for each user handled by XMail.

 

Note: You __CANNOT__ edit this file while XMail is running due to the fact that is an indexed file.

 

 

[MESSAGE.ID]

Is a file storing a sequential message number. You set it at 1 when you install the server and leave it to be handled by XMail.

 

 

[POP3LINKS.TAB]

"local-domain"[TAB]"local-account"[TAB]"external-domain"[TAB]"external-account"[TAB]"external-crypted-password"[TAB]"authtype"[NEWLINE]

authtype = authentication method (CLR=USER/PASS auth, APOP=APOP auth)

Ex:

"home.bogus" "dlibenzi" "xmailserver.org" "dlibenzi" "XYZ..." "APOP"

This entry is used to synchronize the external account "dlibenzi@xmailserver.org" with the encrypted password "XYZ..." with the local account "dlibenzi@home.bogus" using APOP authentication.

 

It connects with the "xmailserver.org" POP3 server and downloads all messages for "dlibenzi@xmailserver.org" into the local account "dlibenzi@home.bogus".

The remote server must support APOP authentication to specify APOP as 'authtype'.

Even if using APOP authentication is more secure because clear usernames and passwords do not travel on the network, if you're not sure about it, specify CLR as 'authtype'.

 

For non local POP3 sync you have to specify a line like this one (@ as the first domain character):

"@home.bogus.com" "dlibenzi" "xmailserver.org:110" "dlibenzi" "XYZ..." "CLR"

 

This entry is used to syncronize the external account "dlibenzi@xmailserver.org" with the encrypted password "XYZ..." with the account "dlibenzi@home.bogus.com" using CLR authentication.

The message will be pushed into the spool having as destination dlibenzi@home.bogus.com, so you must have some kind of processing for that user or domain in your XMail configuration (for example, custom domain processing).

 

You also have the option to setup a line like this one:

"?home.bogus.com,felins.net,pets.org" "dlibenzi" "xmailserver.org" "dlibenzi" "XYZ..." "CLR"

and messages are dropped inside the spool by following these rules:

  1. XMail parses the message headers by searching for To:, Cc: and Bcc: addresses

  2. Each address domain is compared with the list of valid domains (felins.net, pets.org, etc.)

  3. For each valid address the username part is picked up and joined with the '@' and the masquerade domain name (the name following '?')

  4. The message is spooled with the above built destination address

Obviously the masquerade domain ('home.bogus.com') MUST be handled by the server or MUST be a valid external mail domain.

So if a message having a To: address graycat@felins.net is fetched by the previous line a message is pushed into the spool with address graycat@home.bogus.com.

Particular attention must to be taken to avoid mail loops.

 

Another option is:

"&.local,felins.net,pets.org" "dlibenzi" "xmailserver.org" "dlibenzi" "XYZ..." "CLR"

where a fetched message whose To: address is graycat@felins.net will be replaced with graycat@felins.net.local.

You can avoid the matching domain list after the masquerading domain but, in that case, you may have bad destination addresses inside the spool.

 

Note: The list MUST be comma separated WITHOUT spaces.

 

XMail will start PSYNC session with a delay that you can specify with the -Yi nsec command line parameter (default is 120).

XMail will also check for the presence (inside MAIL_ROOT) of a file named ".psync-trigger" and, when this file is found, a PSYNC session will start and this file will be removed.

 

 

[SERVER.TAB]

"varname"[TAB]"varvalue"[NEWLINE]

 

This file contains server configuration variables documented in "Part 12 - SERVER.TAB variables".

 

 

[SMTPGW.TAB]

"domain"[TAB]"smtp-gateway"[NEWLINE]

Ex:

"foo.example.com" "@xmailserver.org"

will send all mail for "foo.example.com" through the "xmailserver.org" SMTP server, while:

"*.dummy.net" "@relay.xmailserver.org"

will send all mail for "*.dummy.net" through "relay.xmailserver.org".

 

The smtp-gateway can be a complex routing also.

Ex:

"*.dummy.net" "@relay.xmailserver.org,@mail.nowhere.org"

will send all mail for "*.dummy.net" through "@relay.xmailserver.org,@mail.nowhere.org",

following this exact way: relay.xmailserver.org --> mail.nowhere.org --> @DESTINATION

 

Note: As many MTAs are not supporting explicit routing you are likely to use the SMTPFWD.TAB documented below instead of SMTPGW.TAB.

 

 

[SMTPFWD.TAB]

"domain"[TAB]"smtp-mx-list"[NEWLINE]

Ex:

"foo.example.com" "mail.xmailserver.org:7001,192.168.1.1:6123,mx.xmailserver.org"

will send all mail for "foo.example.com" using the provided list of mail exchangers, while:

"*.dummy.net" "mail.xmailserver.org,192.168.1.1,mx.xmailserver.org:6423"

will send all mail for "*.dummy.net" through the provided list of mail exchangers.

 

If the port (:nn) is not specified the default SMTP port (25) is assumed.

You can also enable XMail to random-select the order of the gateway list by specifying :

"*.dummy.net" "#mail.xmailserver.org,192.168.1.1,mx.xmailserver.org:6423"

using the # character as the first character of the gateway list.

 

This file allows you to specify a different SMTP server for each domain handled by XMail (while the "DefaultSmtpGateway" value of the Server.tab file only defines a global SMTP server).

 

 

[SMTPRELAY.TAB]

"ipaddr"[TAB]"netmask"[NEWLINE]

Ex:

"212.131.173.0"[TAB]"255.255.255.0"[NEWLINE]

Allows all hosts of the class "C" network "212.131.173.XXX" to use the server as relay.

 

 

[SMTPAUTH.TAB]

"username"[TAB]"password"[TAB]"permissions"[NEWLINE]

is used to permit SMTP client authentication with the PLAIN, LOGIN, CRAM-MD5 and 'custom' protocols.

With custom authentication a file containing all secrets (username + ':' + password) is passed as a parameter to the custom authentication program which will test all secrets to find the one matching pair (if any).

 

For this reason it's better to keep the number of entries in this file as low as possible.

Permissions are a string that can contain:

M = open mailing features

R = open relay features           (bypass all other relay blocking traps)

V = VRFY command enabled    (bypass SERVER.TAB variable)

T = ETRN command enabled    (bypass SERVER.TAB variable)

Z = disable mail size checking (bypass SERVER.TAB variable)

When PLAIN, LOGIN or CRAM-MD5 authentication mode are used a first lookup in MAILUSERS.TAB

accounts is performed to avoid duplicating information with SMTPAUTH.TAB.

So using these authentication modes a user must use as username the full email address (the ':' separator is permitted instead of '@') and as password his POP3 password.

 

If the lookup succeeds then the SERVER.TAB variable "DefaultSmtpPerms" is used to assign user SMTP permissions (default MR). If the lookup fails then a SMTPAUTH.TAB lookup is done.

 

 

[SMTPEXTAUTH.TAB]

Besides internal SMTP authentication methods a user (XMail administrator) can define custom authentication procedures by setting up properly this file.

 

In the section "SMTP Client Authentication" we can see at the client part of the custom authentication when we put an "external" line inside the configuration file. The file SMTPEXTAUTH.TAB is the server part of the custom authentication which has the given format:

 

"auth-name"[TAB]"base-challenge"[TAB]"program-path"[TAB]"arg-or-macro"...[NEWLINE]

This file can contain multiple lines whose "auth-name" will be listed during the EHLO command response. Where "arg-or-macro" can be:

 

@@CHALL = server challenge given by base-challenge + ':' + server-timestamp

@@DGEST = client response to server challenge (@@CHALL)

@@FSECRT = a file containing all the lines (username + ':' + password) of SMTPAUTH.TAB

Ex:

"RSA-AUTH" "foochallenge" "/usr/bin/myrsa-authenticate" "-c"

"@@CHALL" "-f" "@@FSECRT" "-d" "@@DGEST"

 

The external program must test all the lines of @@FSECRT to find a match (if any ) with the client digest (@@DGEST). If it finds a match then it must return zero and overwrite @@FSECRT with the

matching secret (username + ':' + password). If a match is not found then the program must return a value different from zero.

 

 

[USERDEF.TAB]

"varname"[TAB]"varvalue"[NEWLINE]

Ex:

"RealName" "??"

"HomePage" "??"

"Address" "??"

"Telephone" "??"

"MaxMBSize" "10000"

Contains default values for new users that are not set during the new account creation. This file is looked up in two different places: first in $MAIL_ROOT/domains/DOMAIN and then in $MAIL_ROOT, where DOMAIN is the name of the domain where we are going to create the new user.

 

For each "domain" handled by the server we will create a directory "domain" inside $MAIL_ROOT. In $MAIL_ROOT/"domain" yu will find "domain" and "account" directories ($MAIL_ROOT/"domain"/"account"). This folder contains a subfolder named mailbox (or Maildir/(tmp,new,cur)) that stores all the messages of the account "account".

It also contains a file named USER.TAB that stores "account" variables.

Ex:

"RealName" "Davide Libenzi"

"HomePage" "http://www.xmailserver.org/davide.html"

"MaxMBSize" "30000"

 

 

[CTRLACCOUNTS.TAB]

"username"[TAB]"password"[NEWLINE]

This file contains the user accounts that can remotely administer XMail.

The password is encrypted with the XMCrypt program supplied with the source distribution.

 

Note: REMEMBER THAT THIS HOLDS ADMIN ACCOUNTS, SO PLEASE CHOOSE COMPLEX USERNAMES AND PASSWORDS AND USE CTRL.IPMAP.TAB TO RESTRICT IP ACCESS!

REMEMBER TO REMOVE THE EXAMPLE ACCOUNT FROM THIS FILE!

 

 

[SPAMMERS.TAB]

"ipaddr"[TAB]"netmask"[NEWLINE]

Ex:

"212.131.173.0"[TAB]"255.255.255.0"[NEWLINE]

Registers all hosts of the class "C" network "212.131.173.XXX" as spammers, and denies them the ability to use the XMail SMTP server.

 

 

[SPAM-ADDRESS.TAB]

"spam-address"[NEWLINE]

Ex:

"*@rude.net"[NEWLINE]

"*-admin@even.more.rude.net"[NEWLINE]

will block mails coming from the entire domain rude.net and comig from all addresses that end with -admin@even.more.rude.net.

 

 

[POP3.IPMAP.TAB]

"ipaddr"[TAB]"netmask"[TAB]"permission"[TAB]"precedence"[NEWLINE]

This file restricts the IP addresses that can access the POP3 server if located in the MAIL_ROOT folder, and restricts the IP addresses that can access a given POP3 user mailbox if this file is located in the user directory.

Ex:

"0.0.0.0"[TAB]"0.0.0.0"[TAB]"DENY"[TAB]"1"[NEWLINE]

"212.131.173.0"[TAB]"255.255.255.0"[TAB]"ALLOW"[TAB]"2"[NEWLINE]

 

This configuration denies access to all the IP addresses except the ones of the class "C" network "212.131.173.XXX". Higher precedence wins over lower ones.

 

 

[SMTP.IPMAP.TAB]

"ipaddr"[TAB]"netmask"[TAB]"permission"[TAB]"precedence"[NEWLINE]

This file restricts the IP addresses that can access the SMTP server.

Ex:

"0.0.0.0"[TAB]"0.0.0.0"[TAB]"DENY"[TAB]"1"[NEWLINE]

"212.131.173.0"[TAB]"255.255.255.0"[TAB]"ALLOW"[TAB]"2"[NEWLINE]

 

This configuration denies access to all the IP addresses except the ones of the class "C" network "212.131.173.XXX". Higher precedence wins over lower ones.

 

 

[CTRL.IPMAP.TAB]

"ipaddr"[TAB]"netmask"[TAB]"permission"[TAB]"precedence"[NEWLINE]

This file restricts the IP addresses that can access the CTRL server.

Ex:

"0.0.0.0"[TAB]"0.0.0.0"[TAB]"DENY"[TAB]"1"[NEWLINE]

"212.131.173.0"[TAB]"255.255.255.0"[TAB]"ALLOW"[TAB]"2"[NEWLINE]

 

This configuration denies access to all the IP addresses except the ones of the class "C" network "212.131.173.XXX". Higher precedence wins over lower ones.

 

 

[FINGER.IPMAP.TAB]

"ipaddr"[TAB]"netmask"[TAB]"permission"[TAB]"precedence"[NEWLINE]

This file restricts the IP addresses that can access the FINGER server.

Ex:

"0.0.0.0"[TAB]"0.0.0.0"[TAB]"DENY"[TAB]"1"[NEWLINE]

"212.131.173.0"[TAB]"255.255.255.0"[TAB]"ALLOW"[TAB]"2"[NEWLINE]

 

This configuration denies access to all the IP addresses except the ones of the

class "C" network "212.131.173.XXX". Higher precedence wins over lower ones.

 

 

[USER.TAB]

"variable"[TAB]"value"[NEWLINE]

stores user information like:

"RealName" "Davide Libenzi"

"HomePage" "http://www.xmailserver.org/davide.html"

"MaxMBSize" "30000"

"ClosedML" "0"

 

Note: User.tab is not userdef.tab (userdef.tab is used by Crtl to add users while user.tab is edited manually to add users).

 

 

[MLUSERS.TAB]

If the user is a mailing list this file must exist in the user account subdirectory and contains a list of users that have subscribed to this list. The file format is:

"user"[TAB]"perms"[NEWLINE]

where:

user = subscriber email address

perms = subscriber permissions (R = read or RW = read/write)

 

Ex:

"davidel@xmailserver.org" "RW"

"ghostuser@nightmare.net" "R"

 

If the USER.TAB file defines a "ClosedML" variable set to '1' then a client can post to this mailing list only if he is listed in the MLUSERS.TAB file with the "RW" permissions.

 

 

[MAILPROC.TAB]

"command"[TAB]"arg-or-macro"[TAB]...[NEWLINE]

Defines (internal or external) commands that have to be executed on INCOMING message files. The presence of this file is optional an if it does not exist the default is to store the message in each user mailbox.

 

Arg-or-macro can be:

@@FROM will be substituted with the sender of the message

@@RCPT will be substituted with the recipient of the message

@@RRCPT will be substituted with the real recipient (@@RCPT could be an alias) of the message

@@FILE will be substituted with the message file path (the external command _must_ only read the file)

@@MSGID will be substituted with the (XMail unique) message id

@@MSGREF will be substituted with the reference SMTP message id

@@TMPFILE will create a copy of the message file to a temporary file. It can be used with "external" commands but in this case this is the external program responsibility to delete the temporary file.

 

Command can be:

[EXTERNAL]

"external"[TAB]"priority"[TAB]"wait-timeout"[TAB]"command-path"[TAB]"arg-or-macro"[TAB]...[NEWLINE]

where:

external = command keyword

priority = process priority - 0 = normal -1 = below normal +1 = above normal

wait-timeout = delay for process execution in seconds (0 = no delay)

If wait-timeout = 0 then you must add a "wait" command at the end of MAILPROC.TAB to give external commands enought time to read the message file because this file is a temporary file that will be deleted when XMail will have processed the MAILPROC.TAB file.

[MAILBOX]

"mailbox"[NEWLINE]

With this command the message will be pushed into the local user mailbox.

[REDIRECT]

"redirect"[TAB]"address"[TAB]...[NEWLINE]

Redirects messages to internal or external addresses.

[LREDIRECT]

"lredirect"[TAB]"address"[TAB]...[NEWLINE]

Redirects message to internal or external addresses impersonating local domain during messages delivery.

[WAIT]

"wait"[TAB]"timeout"[NEWLINE]

Waits "timeout" seconds. This command is used to give external commands enough time to read the

temporary message file when those commands are launched with a wait-timeout = 0.

Ex:

"[MAILBOX]"[TAB]"0"[TAB]""[TAB]"@@MSGID"[NEWLINE]

 

Part 8 - External Authentication

You can use external modules (executable files) to perform user authentication instead of using XMail mailusers.tab lookups. In the userauth directory you will find one directory for each service whose authentication can be handled externally (currently only for POP3).

Supposing that we have to authenticate USERNAME from DOMAIN, XMail will first try to lookup (from userauth/pop3) a file named:

DOMAIN.tab

else:

.tab

If one of these files is found, XMail will authenticate USERNAME - DOMAIN using this file.

 

The authentication file is a TAB file (see "configuration files" in Part 7) which has the following structure:

"auth-action"[TAB]"command"[TAB]"arg-or-macro"[TAB]...[NEWLINE]

Each argument can be:

@@USER will be substituted with the USERNAME to authenticate

@@DOMAIN will be substituted with the DOMAIN to authenticate

@@PASSWD will be substituted with the user password

@@PATH will be substituted with the user path

The values for "auth-action" can be:

userauth = executed when user authentication is required

useradd = executed when a user need to be added

useredit = executed when a user change is needed

userdel = executed when a user deletion is needed

domaindrop = executed when all domain users need to be deleted

The first line that stores the handling command for the requested action is executed as:

command arg0 ... argN

that in case of success must return zero. Any other exit code will be interpreted as authentication operation failure, which, in the 'userauth' case means that this user will be not authenticated.

 

If the execution of the command fails for a system reason (command not found, access denied, etc.) then the user will not be authenticated.

If none of these files is found then usual authentication is performed (with mailusers.tab).

 

Note: The external authentication does not replace the purpose of the user entry in the mailusers.tab file (which is mandatory).

Part 9 - SMTP Client Authentication

When a message is to be sent through a SMTP server that requires authentication, XMail provides a way to handle this task by setting up the userauth/smtp subdirectoryproperly.

 

Suppose that a mail is to be sent through the SMTP server mail.foo.net, this makes XMail to search for a file named (in userauth/smtp):

mail.foo.net.tab

then:

foo.net.tab

then:

net.tab

If one of these files is found then its content is used to authenticate the SMTP client session. The structure of this file, is the TAB format used for most of the XMail configuration files. The first uncommented line (not begining by the '#' character) is used to choose the authentication method and the following lines have the following format:

"auth-type"[TAB]"param1"...[TAB]"paramN"[NEWLINE]

Valid lines are:

"plain" "username" "password"

or

"login" "username" "password"

or

"cram-md5" "username" "password"

or

"external" "auth-name" "secret" "prog-path" "arg-or-macro" ...

Where "auth-name" can be any symbolic name and "arg-or-macro" can be a program argument or one of the following:

@@CHALL = server challenge string

@@SECRT = authentication secret

@@RFILE = output response file path

Ex:

"external" "RSA-AUTH" "mysecret" "/usr/bin/myrsa-auth" "-c" "@@CHALL" "-s" "@@SECRT" "-f" "@@RFILE"

 

XMail will send a line like: "AUTH RSA-AUTH" to the SMTP server, and wait for a line like: "3?? base64-challenge".

 

Then XMail will decode the base64-challenge and invoke the external program to get the response to send to the SMTP server. The external program must return zero in case of success and must put the

response into the file specified by "@@RFILE" (without new line termination).

If a message that has as target domain sub1.sub2.domain.net comes to XMail then XMail will decide if this domain will require a custom domain processing by trying to lookup the following file:

sub1.sub2.domain.net.tab

.sub2.domain.net.tab

.domain.net.tab

.net.tab

.tab  in the 'custdomains' directory.

If one of these files is found then the incoming mail will get a custom domain processing by executing

commands that are stored in this file.

 

The .tab file format is:

"command"[TAB]"arg-or-macro"[TAB]...[NEWLINE]

store commands (internals or externals) that have to be executed on the message file. The presence of this file is optional an if it does not exist then the default processing is to send the message via SMTP.

Each argument can be:

@@FROM will be substituted with the sender of the message

@@RCPT will be substituted with the target of the message

@@FILE will be substituted with the message file path (the external command _must_ only read the file)

@@MSGID will be substituted with the (XMail unique) message id

@@MSGREF will be substituted with the reference SMTP message id

@@TMPFILE will create a copy of the message file to a temporary file

It can be used with "external" commands but in that case this is the external program responsibility to delete the temporary file.

 

Supported commands are:

 

[EXTERNAL]

"external"[TAB]"priority"[TAB]"wait-timeout"[TAB]"command-path"[TAB]"arg-or-macro"[TAB]...[NEWLINE]

where:

external = command keyword

priority = process priority - 0 = normal -1 = below normal +1 = above normal

wait-timeout = delay to process execution in seconds (0 = no delay)

if wait-timeout = 0 then you must add a "wait" command at the end of the file to give the external commands enough time to read the message file because this file is a temporary file that will be deleted when XMail will have processed this file.

 

[REDIRECT]

"redirect"[TAB]"domain-or-emailaddress"[TAB]...[NEWLINE]

Redirects a message to an internal or external domain or an email address.

If the message is for foo-user@custdomain.net and the file custdomain.net.tab contains:

"redirect" "target-domain.org" 

then the message is delivered to foo-user@target-domain.org.

The line:

"redirect" "user@target-domain.org"

will redirect the message to user@target-domain.org.

 

[LREDIRECT]

"lredirect"[TAB]"domain-or-emailaddress"[TAB]...[NEWLINE]

Redirects a message to an internal or external domain or an email address impersonating a local domain during message delivery.

If the message is for foo-user@custdomain.net and the file custdomain.net.tab contains:

"redirect" "target-domain.org"

then the message is delivered to foo-user@target-domain.org 

The line:

"redirect" "user@target-domain.org"

will redirect the message to user@target-domain.org.

 

[WAIT]

"wait"[TAB]"timeout"[NEWLINE]

Waits "timeout" seconds.

This command is used to give external commands the time to read the temporary message file when these commands are launched with wait-timeout = 0.

 

[SMTPRELAY]

"smtprelay"[TAB]"server[:port],server[:port],..."[NEWLINE]

Sends mail to the specified SMTP server list by trying the first server, and then using the second in case of failure, and so on. You can also use the following syntax:

"smtprelay"[TAB]"#server[:port],server[:port],..."[NEWLINE]

so XMail will select randomly a SMTP relay server from this list.

 

[SMTP]

"smtp"[NEWLINE]

Does SMTP delivery.

 

Part 11 - CmdAliases

CmdAliases implements aliases that are handled only through commands and can be considered a user level implementation of custom domain processing commands.

 

The command set is the same than the one described above in the custom domain processing section and it won't be explained again here (see "Part 10 - Custom domain mail processing").

 

For every handled domain (listed in the domains.tab file) a directory with the name of the domain is created in the 'cmdaliases' subdirectory. This directory is automatically created and removed when you add/remove domains through the CTRL protocol (or CtrlClnt).

 

When a mail from USER@DOMAIN is received by XMail and the domain DOMAIN is to be handled locally, if the standard users/aliases lookup fails, then a file named USER.tab is searched in the folder $MAIL_ROOT/cmdaliases/DOMAIN.

 

If this file is found then commands listed in this file (the file format is described in the previous section) are executed by the server in order to process the mail message.

 

Note: All domains and user names, when applied to the file system, must be lower case.

 

Use of the command [SMTP] must be done with care because it can create mail loops in XMail.

Part 12 - SERVER.TAB variables

 

[RootDomain]

Indicate the primary domain for the server.

 

[POP3Domain]

Set the default domain for POP3 client connections.

 

[PostMaster]

Set the postmaster email address (postmaster@mydomain.com).

 

[ErrorsAdmin]

The email address that will receive notification messages for every message that has had delivery errors. It can be empty and in such case the notification message will be sent only to the sender.

 

[TempErrorsAdmin]

The email address that will receive notification for temporary delivery failures.

In case it is empty the notification message will be sent only to the sender.

 

[DefaultSMTPGateways]

A comma separated list of SMTP servers XMail _must_ use to send emails.

This has the precedence over MX records.

 

[HeloDomain]

If this variable is specified and its value is not empty, its content will be sent as the HELO domain.

Otherwise the reverse lookup of the local IP will be sent as the HELO domain. This will help to deal with remote SMTP servers that are configured to check the reverse lookup of the incoming IP.

 

[CheckMailerDomain]

Enable validation of the sender domain ("MAIL FROM:<...@xxx>") by looking up DNS/MX entries.

 

[RemoveSpoolErrors]

Indicate if mail has to be removed or stored in froz directory after a failure in delivery or filtering.

 

[NotifyMsgLinesExtra]

Number of lines of the bounced message that have to be listed in the notify message (lines after

the headers section). Default is zero.

 

[NotifySendLogToSender]

Enable/Disable the transmission of the message log file in the notify message to the sender.

Default is off ("0", zero).

 

[NotifyTryPattern]

List of delivery attempts that require the system to send a notification to the sender (and eventually to TempErrorsAdmin). This is a comma separated list of number (with no spaces) like:

"1,4,9"

Default is empty that means that no notification is sent upon a delivery attempt failure.

 

[AllowNullSender]

Enable null sender ("MAIL FROM:<>") messages to be accepted by XMail.

 

[MaxMTAOps]

Set the maximum number of MTA relay steps before to declare the message as looped (default 16).

 

[ReceivedHdrType]

Set the verbosity of the Received: message headers tag.

0 = Standard (client IP shown, server IP not). Default.

1 = Verbose  (client IP shown, server IP shown)

2 = Strict      (no IP shown)

 

[FetchHdrTags]

Set the list of headers tags to be used to extract addresses from POP3 fetched messages (POP3LINKS.TAB). This is a comma delimited list (no spaces or TABs must be used):

 

"+X-Deliver-To,To,Cc"

 

Tags preceded by a '+' character will make XMail to stop scanning when an address is found inside such a header tag. Tags preceded by a '+' character must be listed before other tags.

 

The string "+X-Deliver-To,To,Cc" is the default if nothing is specified.

 

[AllowSmtpVRFY]

Enable the use of the VRFY SMTP command. This flag may be forced by SMTP authentication.

 

[AllowSmtpETRN]

Enable the use of the ETRN SMTP command. This flag may be forced by SMTP authentication.

 

[SmtpMinDiskSpace]

Minimum disk space (in KB) necessary to have XMail accept a SMTP connection.

 

[SmtpMinVirtMemSpace]

Minimum virtual memory (in KB) necessary to have XMail accept a SMTP connection.

 

[Pop3MinVirtMemSpace]

Minimum virtual memory (in KB) necessary to have XMail accept a POP3 connection.

 

[Pop3SyncErrorAccount]

This defines the email account (which MUST be handled locally) that will receive all fetched email that XMail has not been able to deliver.

 

[EnableAuthSMTP-POP3]

Enable SMTP after POP3 authentication (default is "1").

 

[MaxMessageSize]

Set the maximum message size (in KB) that it is possible to send with XMail.

 

[DefaultSmtpPerms]

This lists SMTP permissions assigned to users looked up in the file MAILUSERS.TAB during SMTP authentication. It also defines the permissions for users authenticated after a POP3 session.

 

[CustMapsList]

This is a list a user can use to set custom maps checking. The list has the following (strict) format:

maps-root:code,maps-root:code...

 

Where 'maps-root' is the root for the dns query (ie. dialups.mail-abuse.org) and the code can be:

1 = the connection is going to be drooped soon

0 = the connection is kept alive but only authenticated users can send mail

-S = the peer can send messages but a delay of S seconds will be introduced between commands

 

[SMTP-RDNSCheck]

Indicate if XMail must do an RDNS lookup before accepting a incoming SMTP connection.

0 = the check is not performed; 

1 = if the check fails, the user will receive an "server use forbidden" error at MAIL_FROM time; 

-S = (S>0) if the check fail, a delay of S seconds between SMTP commands is used to prevent

massive spamming.

SMTP authentication will override this option by giving authenticated users the ability to access the server from "mapped" IP addresses.

 

[SmartDNSHost]

Setup a list of smart DNS hosts to which are directed DNS queries with the recursion bit set to true. Such DNS hosts must support DNS recursion in queries.

The format is:

dns.home.bogus.net:tcp,192.168.1.1:udp,...

 

[DynDnsSetup]

Allows you to use a fake domain name to use XMail with a changing IP address.

Visit www.dyndns.org, www.dns2go.com, www.no-ip.com, etc. for more information.

The string has the format:

server,port,HTTP-GET-String[,username,password]

Ex:

members.dyndns.org,80,/nic/dyndns?action=edit&started=1&hostname=YES&host_id

=yourhost.ourdomain.ext&myip=%s&wildcard=OFF&mx=mail.exchanger.ext&backmx

=NO,foouser,foopasswd

or

www.dns4ever.com,80,/sys/u.cgi?d=DOMAIN&u=USERNAME&p=PASSWORD&i=%s

where:

DOMAIN = the fake domain name that you have registered

USERNAME = the username you got from service provider

PASSWORD = the password you got from service provider

The %s in HTTP-GET-String must be replaced with the IP address to register.

 

[SmtpConfig]

The default SMTP server that will be loaded if the specified SMTP server IP address is not available.

[SmtpConfig-XXX.YYY.ZZZ.WWW]

The string value is a comma separated sequence of configuration tokens whose meaning is:

mail-auth = authentication is required to send mail to the server.

Please note that setting this value will require authentication even for sending to local domains, and this is probably not what you are wishing.

Ex:

"SmtpConfig" "mail-auth"

this will make it mandatory to authenticate users to send mail through XMail

"SmtpConfig-192.168.0.1" "mail-auth"

same as above but the SMTP Server 192.168.0.1 will be used if the default SMTP server is not ready

Part 13 - Domain message filters

This feature offers a way to filter incoming emails by providing the ability to execute external programs, such as scripts or real executables, that examine (modify or both) the message and give a response by the means of a return value:

  96: the email is OK and can continue its trip
  97: the email is rejected without notification and is deleted
  98: the email is rejected without notification but kept on disk
  99: the email is rejected and a notification is sent to the sender
100: the email is modified and can continue its trip

When a message is received by the SMTP server for user foo@xyzw.abc then XMail searches ins the filters subdirectory to find a file named (user processing):

foo@xyzw.abc.tab

If this file is not found then XMail will look for (domain processing):

xyzw.abc.tab

If this file is not found then XMail will search a file called ".tab" in the filters subdirectory. This offers a way to specify a default mail filtering active for all the domains. If this file is not found then the message will continue its travel, otherwise the message will be submitted to all the filters specified in the *.tab file.

 

Note: To create a file called ".tab" under Windows open a DOS box and type: echo . > .tab

         (Windows will not allow you to create such a file from Explorer -the file manager)

 

The syntax of the *.tab file is:

"command"[TAB]"arg-or-macro"[TAB]...[NEWLINE]

 

Ex:

"C:\MailRoot\bin\MyFilter.exe"[TAB]""C:\MailRoot\bin"[TAB]"@@FILE"

This will invoke the program MyFilter.exe to check all incoming emails.

 

And arg-or-macro can be:

@@FROM will be substituted with the sender of the message

@@RCPT will be substituted with the target of the message

@@FILE will be substituted with the message file path (the external command may modify the file if it's going to return 100 as command exit value)

@@MSGID will be substituted with the (XMail unique) message id

@@MSGREF will be substituted with the reference SMTP message id

Here "command" is the name of an external program that must process the message and return a code. If it returns 99 then the message is rejected and a notification message is sent to the sender. By returning 98 the message will be rejected without notification while by returning 97 the message is rejected without notification and without being frozen (a 98 response could lead to a frozen message if the SERVER.TAB configuration file enabled this).

 

Note: If a filters returns a value different from 99, 98 or 97 then the message can continue its trip.

 

The filter command may also modify the file and return 100, having the ability to change the file content (AV scanning, content filter, message rewriting, etc.).

If the filter changed the message file then it MUST keep the message structure and it MUST terminate all the lines with a <CR><LF>.

The spool files have the following structure:

SmtpDomain         [ 1st line ]

SmtpMessageID    [ 2nd line ]

MAIL FROM:<...>   [ 3th line ]

RCPT TO:<...>      [ 4th line ]

<<MAIL-DATA>>    [ 5th line ]

...

After the "<<MAIL-DATA>>" tag (5th line) the message follows. The message is composed by a header section and, after the first empty line (CR-LF), the message body.

 

To get the C/ C++ source code of ready-to-use email filters visit:

http://www.twd-industries.com/en/xmail.htm      // To patch attachments and HTML Tags

http://software.dolist.net/xscanner.asp             // To scan emails with a list of keywords

Part 14 - USER.TAB variables
 

[RealName]

Full user name:

"RealName" "Davide Libenzi"

 

[HomePage]

User home page:

"HomePage" "http://www.xmailserver.org/davide.html"

 

[MaxMBSize]

Max user mailbox size (in KB):

"MaxMBSize" "30000"

 

[ClosedML]

Specify if the mailing list is closed only to subscribed users:

"ClosedML" "1"

 

[ListSender]

Specify the mailing list sender or administrator:

"ListSender" "ml-admin@xmailserver.org"

This variable should be set to prevent delivery error notifications from reaching the original message senders.

 

[SmtpPerms]

User SMTP permissions (see the SMTPAUTH.TAB file for more information).

 

[ReceiveEnable]

"1" if the account can receive email, "0" if you do not want the account to receive messages.

 

[PopEnable]

"1" if you want the account to fetch POP3 messages, "0" otherwise.

 

[UseReplyTo]

Enable/disable the 'Reply-To:' header for mailing list messages (default is "1").

 

[MaxMessageSize]

Set the maximum message size (in KB) that the user will be able to send through XMail. This option overrides the SERVER.TAB variable.

Part 15 - Mail Routing Through Addresses

A full implementation of the SMTP protocol includes the ability to perform mail routing bypassing DNS MX records by using the the "RCPT TO: <>" request.

 

If an email from xuser@hostz directed to @hosta,@hostb:foouser@hostc is received by @hosta then it will be sent to @hostb using        "MAIL FROM:<@hosta:xuser@hostz>"

                                    and "RCPT TO: <@hostb:foouser@hostc>" and then:

it will be sent to @hostc using "MAIL FROM:<@hostb,@hosta:xuser@hostz>"

                                    and "RCPT TO: <foouser@hostc>".

Part 16 - The XMail Spool

The new spool tree has been designed to enable XMail to handle very large queues. Instead of having a single spool directory (like versions older than 0.61) a two layer deep splitting has been introduced:

0 <dir>

0 <dir>

mess <dir>

rsnd <dir>

info <dir>

temp <dir>

slog <dir>

cust <dir>

froz <dir>

...

...

When XMail needs to create a new spool file a spool path is chosen randomly way and a new file with the format mstime.pid.hostname is created in the temp subdirectory.

When the spool file is ready to be committed, it is moved in the mess subdirectory that holds newer spool files. If XMail fails to send a new message (the ones located in the mess subdirectory) then it creates a log file (with the name of the message file) in the slog subdirectory and moves the file from mess directory to the rsnd folder.

 

During the message processing the message itself is locked by creating a file inside the lock subdirectory (with the name of the message file). If the message has permanent delivery errors or has expired and if the option "RemoveSpoolErrors" of the SERVER.TAB file is off, then the message file is moved in the froz subdirectory.

Part 17 - SMTP commands

The following commands are understood by the XMail ESMTP server:

 

MAIL FROM:<> provides the source email address
RCPT TO:<> provides the destination email address
DATA sends the text of the message (the message ends with a '.' on a new line)
HELO identifies the host
EHLO identifies the host and provides extended information
AUTH specifies the authentication scheme
RSET cancels the message
VRFY checks if an email address exists
ETRN instructs a server to use a domain for delayed delivery
NOOP does nothing other than elicit a response from the server
HELP requests online help from the server (it will list the commands it supports)
QUIT ends the SMTP session

 

RFC 821 requires that every server support the HELO, RSET, NOOP, MAIL, RCPT, DATA and QUIT verbs ( verbs are not case sensitive but it is much safer to use UPPERCASE verbs since many clients and servers will close the connection if you send 'Hello' or 'hEllO'). 

Part 18 - POP3 commands

The following commands are understood by the XMail POP3 server :

 

USER Indicates a username
PASS Provides a password (in plain text)
APOP Provides a password encrypted with MD5
STAT Used by the Client to ask the Server how many emails are waiting to be retrieved
LIST Used by the Client to ask the Server to list the emails that are waiting to be retrieved
UIDL Used by the Client to get the ID of a given message
QUIT Close a POP3 session
RETR Retrieve a message
TOP Allows the Server to send the client a partial view of the pending emails (Nbr of lines)
DELE Delete a message
NOOP Used by the Client to get an acknowledge from the Server
LAST Returns the number of undeleted messages in the mailbox and the mailbox size in bytes
RSET Used by the Client to ask the Server not to delete emails after retrieval

Most of the XMail configuration settings can be changed from the XMail command line:

 

[XMAIL]

-Ms pathname The Mail root path also defined by the MAIL_ROOT environment variable
-Md Enable the debug ( verbose ) mode
-Mr hours Set the log rotation step (in hours)
-Mx split-level The queue split level (rounded to the lowest prime number higher or equal)
-MR bytes Set the size of the socket's receive buffer in bytes (rounded up to a multiple of 1024)
-MS bytes Set the size of the socket's send buffer in bytes (rounded up to a multiple of 1024)

 

[POP3]

-Pp port Set the POP3 server port ( if you change this you must know what you're doing )
-Pt timeout Set the POP3 session timeout (in seconds ) after which the server will close the connection if no commands were received
-Pw timeout Enable POP3 logging
-Pl

Set the delay in response to a bad POP3 login. This delay will be doubled after the next bad login

-Ph Hang the connection in case of a bad login response
-PI ip[:port] Bind the server to the specified IP address and ( optional) port ( can be multiple )
-PX nthreads Set the maximum number of threads for the POP3 server

 

[SMTP]

-Sp port Set the SMTP server port ( if you change this you must know what you're doing )
-St timeout

Set the SMTP session timeout (in seconds ) after which the server will close the connection if no command is received

-Sl Enable SMTP logging
-SI ip[:port] Bind the server to the specified IP address and ( optional) port ( can be multiple )
-SX nthreads Set the maximum number of threads for the SMTP server
-Sr maxrcpts Set the maximum number of recipients for a single SMTP message ( default 100 )
-Se nsecs Set the expire timeout for a POP3 authenticated IP address ( default 900 )

 

[SMAIL]

-Qn nthreads Set the number of mailer threads
-Qt timeout Set the delay (in seconds) to wait be fore new try after a send failure. Default 480
-Qi ratio Set the increment ratio of the reschedule time when sending a message. After a failure to deliver a message, reschedule time T is incremented by ( T / ratio ), therefore T(i) = T(i-1) +T(i-1)/ratio. If you set this ratio to zero, T remains unchanged over delivery attempts. The default value is 16.
-Qr nretries Set the maximum number of times to try to send a message. Default: 32.
-Ql Enable SMAIL logging

 

[PSYNC]

-Yi interval Set external POP3 accounts sync interval (in seconds). Default: 120 
-Yt nthreads Set the number of POP3 sync threads

 

[FINGER]

-Fp port Set the FINGER port (if you change this you must know what you're doing)
-Fl Enable FINGER logging
-FI ip[:port] Bind server to the specified IP address and ( optional) port (can be multiple)

 

[CTRL]

-Cp port Set the CTRL port ( if you change this you must know what you're doing )
-Ct timeout

The delay (in seconds) after which the server will close the connection if no command was received

-Cl Enable CTRL logging
-CI ip[:port]  Bind the server to the specified IP address and ( optional) port ( can be multiple )
-CX nthreads Set the maximum number of threads for CTRL server

 

[LMAIL]

-Ln nthreads Set the number of local mailer threads
-Lt timeout Set the sleep timeout for LMAIL threads (in seconds, default is 2)
-Ll Enable local mail logging

It is possible to administrate remotely XMail: a "Controller server" is waiting for TCP/IP connections on port 6017 (change it via the command line switch "-Cp nport" documented in "Part 19 - Command line").

 

The XMail Admin Server "speaks" a protocol that can be used by external GUI utilities written with the more disparate scripting languages to administer remotely the mail server. The protocol is based on the idea of sending formatted strings of commands and waiting for formatted server responses and error codes. All the lines, commands and responses, are terminated by a <CR><LF> pair.

 

The error code string (I'll call it RESSTRING) has the following format:

"+DDDDD OK"<CR><LF> if the command execution is successful and:

"-DDDDD ErrorString"<CR><LF> if the command failed (the " character is not included in responses).

 

DDDDD is a numeric error code and ErrorString is a description of the error.

If DDDDD equals 00100 then a list of text lines terminated by a line with a single point (<CR><LF>.<CR><LF>) will follow the response.

 

 

The format for commands is similar to the format used in TAB files:

"cmdstring"[TAB]"param1"[TAB]..."paramN"<CR><LF>

where "cmdstring" is the command string identifying the action to be performed, and param1,... are the parameters of the command.

Immediately after the connection with the XMail Controller Server is established the client will receive a RESSTRING:

+00000 <TimeStamp> XMail ... if the server is ready, and:

-DDDDD ... (where DDDDDD is an error code) if this is not the case.

The TimeStamp string has the following format:

currtime.pid@ipaddress

and will be used in the MD5 authentication procedure.

 

 

XMail Controller loggin

As the first action immediately after the connection the client must send an authentication string :

"user"[TAB]"password"<CR><LF>

where "user" must be enabled to remotely administer XMail. This in case when using a plain text password -something that you should not do if the server security is a concern.

 

Using the MD5 authentication instead, the client must perform a MD5 checksum on the string composed by (<> included):

<TimeStamp>password and then send the following to the server:

"user"[TAB]"#md5chksum"<CR><LF> where md5chksum is the MD5 checksum (note the ' #' sent as the first character of the digest).

The result of the authentication send will be a RESSTRING.

If the user does not receive a positive authentication response then the connection will be closed by the server.

 

 

XMail Controller commands

Adding a user

"useradd"[TAB]"domain"[TAB]"username"[TAB]"password"[TAB]"usertype"<CR><LF>

where:

domain = domain name (must be handled by the server)

username = username to add

password = user password

usertype = "U" for normal user and "M" for mailing list

The result will be a RESSTRING.

 

Deleting a user

"userdel"[TAB]"domain"[TAB]"username"<CR><LF>

where:

domain = domain name (must be handled by the server)

username = username to delete

The result will be a RESSTRING.

 

Changing user password

"userpasswd"[TAB]"domain"[TAB]"username"[TAB]"password"<CR><LF>

where:

domain = domain name (must be handled by the server)

username = username (must exist)

password = new password

The result will be a RESSTRING.

 

Authenticate user

"userauth"[TAB]"domain"[TAB]"username"[TAB]"password"<CR><LF>

where:

domain = domain name

username = username

password = password

The result will be a RESSTRING.

 

Retrieve user statistics

"userstat"[TAB]"domain"[TAB]"username"<CR><LF>

where:

domain = domain name

username = username/alias

The result will be a RESSTRING.

In case of success (00100) a formatted matching list of users will follow, terminated by a line containing a single dot (<CR><LF>.<CR><LF>).

This is the format of the listing:

"variable"[TAB]"value"<CR><LF>

Where valid variables are:

RealAddress = real address (may be different if the supplied username is an alias)

MailboxSize = total size of the mailbox in bytes

MailboxMessages = total number of messages

LastLoginIP = last user login IP address

 

Adding an alias

"aliasadd"[TAB]"domain"[TAB]"alias"[TAB]"username"<CR><LF>

where:

domain = domain name (must be handled by the server)

alias = alias to add

username = real email account (locally handled)

The result will be a RESSTRING.

 

Deleting an alias

"aliasdel"[TAB]"domain"[TAB]"alias"<CR><LF>

where:

domain = domain name (must be handled by the server)

alias = alias to delete

The result will be a RESSTRING.

 

Listing aliases

"aliaslist"[TAB]"domain"[TAB]"alias"[TAB]"username"<CR><LF>

or

"aliaslist"[TAB]"domain"[TAB]"alias"<CR><LF>

or

"aliaslist"[TAB]"domain"<CR><LF>

or

"aliaslist"<CR><LF>

where:

domain = domain name, optional (can contain wildcards)

alias = alias name, optional (can contain wildcards)

username = username, optional (can contain wildcards)

Ex:

"aliaslist"[TAB]"foo.bar"[TAB]"*"[TAB]"mickey"<CR><LF>

will list all aliases of the user "mickey" for the domain "foo.bar".

The result will be a RESSTRING.

 

In case of success (00100) a formatted list of matching users will follow, terminated by a line containing a single dot (<CR><LF>.<CR><LF>).

This is the format of the listing:

"domain"[TAB]"alias"[TAB]"username"<CR><LF>

 

Listing user variables

"uservars"[TAB]"domain"[TAB]"username"<CR><LF>

where:

domain = domain name

username = username

The result will be a RESSTRING.

In case of success ( 00100 ) a formatted list of matching users will follow, terminated by a line containing a single dot ( <CR><LF>.<CR><LF>).

This is the format of the listing:

"varname"[TAB]"varvalue"<CR><LF>

 

Setting user variables

"uservarsset"[TAB]"domain"[TAB]"username"[TAB]"varname"[TAB]"varvalue"... <CR><LF>

where:

domain = domain name

username = username

varname = variable name

varvalue = variable value

There can be multiple variable assignments within a single call.

If varvalue is the string ".|rm" then the variable varname is deleted.

The result will be a RESSTRING.

 

Listing users

"userlist"[TAB]"domain"[TAB]"username"<CR><LF>

or

"userlist"[TAB]"domain"<CR><LF>

or

"userlist"<CR><LF>

where:

domain = domain name, optional (can contain wildcards)

username = username, optional (can contain wildcards)

Ex:

"userlist"[TAB]"spacejam.foo"[TAB]"*admin"<CR><LF>

will list all the users of the domain "spacejam.foo" that end with the word "admin".

The result will be a RESSTRING.

In case of success ( 00100 ) a formatted list of matching users will follow, terminated by a line containing a single dot ( <CR><LF>.<CR><LF>).

This is the format of the listing:

"domain"[TAB]"username"[TAB]"password"[TAB]"usertype"<CR><LF>

 

Getting the mailproc.tab file

"usergetmproc"[TAB]"domain"[TAB]"username"<CR><LF>

where:

domain = domain name

username = username

Ex:

"usergetmproc"[TAB]"spacejam.foo"[TAB]"admin"<CR><LF>

will get the mailproc.tab file for the user "admin" in the domain "spacejam.foo".

The result will be a RESSTRING.

In case of success (00100) the mailproc.tab file is listed line by line, and terminated by a single dot (<CR><LF>.<CR><LF>).

 

Setting the mailproc.tab file

"usersetmproc"[TAB]"domain"[TAB]"username"<CR><LF>

where:

domain = domain name

username = username

Ex:

"usersetmproc"[TAB]"spacejam.foo"[TAB]"admin"<CR><LF>

will set the mailproc.tab file for user "admin" of domain "spacejam.foo".

The result will be a RESSTRING.

In case of success (00100) the client must list the mailproc.tab file line by line, and terminate it by a single dot (<CR><LF>.<CR><LF>).

Note: If a line of the file begins with a dot, another dot must be added at the begin of the line.

If the file has a zero length then the mailproc.tab file will be deleted.

The client must then get another RESSTRING indicating the final result of the command.

 

Adding a mailing list user

"mluseradd"[TAB]"domain"[TAB]"mlusername"[TAB]"mailaddress"[TAB]"perms"<CR><LF>

or

"mluseradd"[TAB]"domain"[TAB]"mlusername"[TAB]"mailaddress"<CR><LF>

where:

domain = domain name (must be handled by the server)

mlusername = mailing list username

mailaddress = mail address to add to the mailing list ("mlusername@domain")

perms = user permissions (R or RW)

When perms is not specified the default is RW.

The result will be a RESSTRING.

 

Deleting a mailing list user

"mluserdel"[TAB]"domain"[TAB]"mlusername"[TAB]"mailaddress"<CR><LF>

where:

domain = domain name (must be handled by the server)

mlusername = mailing list username

mailaddress = mail address to delete from the mailing list ("mlusername@domain")

The result will be a RESSTRING.

 

Listing mailing list users

"mluserlist"[TAB]"domain"[TAB]"mlusername"<CR><LF>

where:

domain = domain name (must be handled by the server)

mlusername = mailing list username

The result will be a RESSTRING.

In case of success (00100) a formatted list of mailing list users will follow, terminated by a line containing a single dot (<CR><LF>.<CR><LF>).

 

Adding a domain

"domainadd"[TAB]"domain"<CR><LF>

where:

domain = domain name to add

The result will be a RESSTRING.

 

Deleting a domain

"domaindel"[TAB]"domain"<CR><LF>

where:

domain = domain name to delete

The result will be a RESSTRING. This is not always a safe operation.

 

Listing handled domains

"domainlist"<CR><LF>

or:

"domainlist"[TAB]"wildmatch0"[TAB]...[TAB]"wildmatchN"<CR><LF>

The result will be a RESSTRING.

The wildmatch argument simply returns a filtered list of domains.

In case of success ( 00100 ) a formatted list of domains will follow, terminated by a line containing a single dot ( <CR><LF>.<CR><LF>).

 

Adding a domain alias

"aliasdomainadd"[TAB]"realdomain"[TAB]"aliasdomain"<CR><LF>

Ex:

"aliasdomainadd"[TAB]"xmailserver.org"[TAB]"xmailserver.com"<CR><LF>

defines xmailserver.com as an alias of xmailserver.org

"aliasdomainadd"[TAB]"xmailserver.org"[TAB]"*.xmailserver.org"<CR><LF>

defines all subdomains of xmailserver.org as aliases for xmailserver.org.

 

Deleting a domain alias

"aliasdomaindel"[TAB]"aliasdomain"<CR><LF>

Ex:

"aliasdomaindel"[TAB]"*.xmailserver.org"<CR><LF>

removes the *.xmailserver.org domain alias.

 

Listing alias domains

"aliasdomainlist"<CR><LF>

or:

"aliasdomainlist"[TAB]"wildmatch0"[TAB]...[TAB]"wildmatchN"<CR><LF>

The result will be a RESSTRING.

The wildmatch argument simply returns a filtered list of alias domains.

In case of success (00100) a formatted list of domains will follow, terminated by a line containing a single dot (<CR><LF>.<CR><LF>).

 

Getting the custom domain file

"custdomget"[TAB]"domain"<CR><LF>

where:

domain = domain name

Ex:

"custdomget"[TAB]"spacejam.foo"<CR><LF>

will get the custom domain file for the domain "spacejam.foo".

The result will be a RESSTRING.

In case of success ( 00100 ) the custom domain file is listed line by line, terminated by a line containing a single dot ( <CR><LF>.<CR><LF>).

 

Setting a custom domain file

"custdomset"[TAB]"domain"<CR><LF>

where:

domain = domain name

Ex:

"custdomset"[TAB]"spacejam.foo"<CR><LF>

will set a custom domain file for the domain "spacejam.foo".

The result will be a RESSTRING.

In case of success (00101) the client must list the custom domain file line by line, and end with a line containing a single dot  ( <CR><LF>.<CR><LF>).

If a line of the file begins with a dot then another dot must be added at the begin of the line.

If the file has a zero length then the custom domain file will be deleted.

The client must then get another RESSTRING indicating the result of the final command.

 

Listing custom domains

"custdomlist"<CR><LF>

The result will be a RESSTRING.

In case of success ( 00100 ) 

a formatted list of custom domains will follow, terminated by a line containing a single dot ( <CR><LF>.<CR><LF>).

 

Adding a POP3 external link

"poplnkadd"[TAB]"loc-domain"[TAB]"loc-username"[TAB]"extrn-domain"[TAB]"extrn-username"[TAB]"extrn-password"[TAB]"authtype"<CR><LF>

where:

loc-domain = local domain name (must be handled by the server)

loc-username = local username which will receive mails

extrn-domain = external domain

extrn-username = external username

extrn-password = external user password

authtype = authentication method (CLR=USER/PASS auth APOP=APOP auth)

The remote server must support the APOP authentication to specify APOP as the authentication type.

Even if using the APOP authentication is more secure because clear usernames/passwords do not travel on the network, if you are not sure about how to use it then specify CLR as the authtype.

The result will be a RESSTRING.

 

Deleting a POP3 external link

"poplnkdel"[TAB]"loc-domain"[TAB]"loc-username"[TAB]"extrn-domain"[TAB]"extrn-username"<CR><LF>

where:

loc-domain = local domain name (must be handled by the server)

loc-username = local username which will receive mails

extrn-domain = external domain

extrn-username = external username

The result will be a RESSTRING.

 

Listing POP3 external links

"poplnklist"[TAB]"loc-domain"[TAB]"loc-username"<CR><LF>

or

"poplnklist"[TAB]"loc-domain"<CR><LF>

or

"poplnklist"<CR><LF>

The result will be a RESSTRING.

In case of success (00100) a formatted list of handled domains will follow, terminated by a line containing a single dot (<CR><LF>.<CR><LF>).

The format of the listing is:

"loc-domain"[TAB]"loc-username"[TAB]"extrn-domain"[TAB]"extrn-username"[TAB]"extrn-password"[TAB]"authtype"[TAB]"on-off"<CR><LF>

 

Enabling a POP3 external link

"poplnkenable"[TAB]"enable"[TAB]"loc-domain"[TAB]"loc-username"[TAB]"extrn-domain"[TAB]"extrn-username"<CR><LF>

or

"poplnkenable"[TAB]"enable"[TAB]"loc-domain"[TAB]"loc-username"<CR><LF>

where:

enable = 1 for enabling - 0 for disabling

loc-domain = local domain name

loc-username = local username which will receive mails

extrn-domain = external domain

extrn-username = external username

Note: In the second format all users links are affected by the enable operation.

The result will be a RESSTRING.

 

Listing files

"filelist"[TAB]"relative-dir-path"[TAB]"match-string"<CR><LF>

where:

relative-dir-path = path relative to the MAIL_ROOT path

match-string = wildcard match string for the file selection

The result will be a RESSTRING.

In case of success (00100) the directory is listed line by line, and ends with a line containing a single dot (<CR><LF>.<CR><LF>).

 

Getting a configuration file

"cfgfileget"[TAB]"relative-file-path"<CR><LF>

where:

relative-file-path = path relative to the MAIL_ROOT path

Ex:

"cfgfileget"[TAB]"ctrlaccounts.tab"<CR><LF>

The result will be a RESSTRING.

In case of success (00100) the file is listed line by line, and ends with a line containing a single dot (<CR><LF>.<CR><LF>).

Note: You CANNOT use this command with indexed files!

 

Setting a configuration file

"cfgfileset"[TAB]"relative-file-path"<CR><LF>

where:

relative-file-path = path relative to MAIL_ROOT path

Ex:

"cfgfileset"[TAB]"ctrlaccounts.tab"<CR><LF>

The result will be a RESSTRING.

In case of success (00101) the client must list the configuration file line by line, and end with a line containing a single dot (<CR><LF>.<CR><LF>).

If a line of the file begins with a dot then another dot must be added at the begin of the line.

If the file has a zero length then the configuration file will be deleted.

The client must then get another RESSTRING indicating the result of the final command.

Remember that configuration files have a strict syntax and that by pushing a bad file you can make XMail to stop working properly.

Note: You CANNOT use this command with indexed files!

 

Listing frozen messages

"frozlist"<CR><LF>

The result will be a RESSTRING.

In case of success (00100) a formatted list of frozen messages will follow, ending with a line

containing a single dot (<CR><LF>.<CR><LF>).

The format of the listing is:

"msgfile"[tab]"lev0"[TAB]"lev1"[TAB]"from"[TAB]"to"[TAB]"time"[TAB]"size"<CR><LF>

Where:

msgfile = message name or id

lev0 = queue file system level 0 (first level directory index)

lev1 = queue file system level 1 (second level directory index)

from = message sender

to = message destination

time = message time ("YYYY-MM-DD HH:MM:SS")

size = message size in bytes

 

Rescheduling frozen messages

"frozsubmit"[TAB]"lev0"[TAB]"lev1"[TAB]"msgfile"<CR><LF>

Where:

msgfile = message name or id

lev0 = queue file system level 0 (first level directory index)

lev1 = queue file system level 1 (second level directory index)

You can get this information from the "frozlist" command.

After a message has been successfully rescheduled it'll be deleted from the frozen fs path.

The result will be a RESSTRING.

 

Deleting frozen messages

"frozdel"[TAB]"lev0"[TAB]"lev1"[TAB]"msgfile"<CR><LF>

Where :

msgfile = message name or id

lev0 = queue file system level 0 (first level directory index)

lev1 = queue file system level 1 (second level directory index)

You can get this information from the "frozlist" command.

The result will be a RESSTRING.

 

Getting frozen message log file

"frozgetlog"[TAB]"lev0"[TAB]"lev1"[TAB]"msgfile"<CR><LF>

Where:

msgfile = message name or id

lev0 = queue file system level 0 (first level directory index)

lev1 = queue file system level 1 (second level directory index)

You can get this information from the "frozlist" command.

The result will be a RESSTRING.

In case of success (00100) the frozen message log file will follow, and end with a a line containing a single dot (<CR><LF>.<CR><LF>).

 

Getting frozen messages

"frozgetmsg"[TAB]"lev0"[TAB]"lev1"[TAB]"msgfile"<CR><LF>

Where:

msgfile = message name or id

lev0 = queue file system level 0 (first level directory index)

lev1 = queue file system level 1 (second level directory index)

You can get these info from the "frozlist" command.

The result will be a RESSTRING.

In case of success ( 00100 ) the frozen message file will follow, and end with a a line containing a single dot ( <CR><LF>.<CR><LF>).

 

Starting a queue flush

"etrn"[TAB]"email-match0"...<CR><LF>

Where:

email-match0 = wildcard email matching for destination address

Ex:

"etrn" "*@*.mydomain.com" "your-domain.org"

will start queuing all messages with a matching destination address.

 

Do nothing command

"noop"<CR><LF>

The result will be a RESSTRING.

 

Quit the connection

"quit"<CR><LF>

The result will be a RESSTRING.

 

Are there guys that want to build GUI configuration tools using common scripting languages (Java, TCL/Tk, etc.) and XMail controller protocol? Are there guys that want to build Web configuration tools ?

Let me know at <davidel@xmailserver.org>.

 

Part 21 - XMail local mailer

XMail has the ability to deliver locally prepared mail files. Just put them in the spool/local directory.

The format of these files is strict:

mail from:<...>[CR][LF]

rcpt to:<...>[CR][LF]

...

[CR][LF]

message text with [CR][LF] line termination

All lines must be [CR][LF] terminated, with one mail-from statement, one or more rcpt-to statements, an empty line and the message text.

Mail files must not be created directly in the /spool/local directory but instead in the /spool/temp directory. When the file is ready then only it can be moved in /spool/local.

 

The file name format is:

stime-seqnr.pid.hostname

where:

stime = system time in sec from 01/01/1970

seqnr = sequence number for the current file

pid = process or thread id that generated the local mail

hostname = the host name of the machine where the process that created the mail is running

Ex:

97456928-001.7892.home.bogus

XMail has a number of LMAIL threads that periodically scan the /spool/local directory watching for locally generated mail files. You can modify the number of threads with the "-Ln nthreads" command line option. The suggested number ranges from three to seven.

You can use the CtrlClnt.exe tool to send administrative commands to XMail.

These commands are defined in a previous section (see Part 20 - XMail's administration protocol).

The syntax of the CtrlClnt utility is:

CtrlClnt [-snuptf] ...

-s server = set server address

-n port = set server port [6017]

-u user = set username

-p pass = set password

-t timeout = set timeout [60]

-f filename = set dump filename [stdout]

with commands and parameters using the following syntax:

CtrlClnt -s mail.foo.org -u davide.libenzi -p ciao useradd home.bogus foouser foopasswd U

will execute the command useradd with the parameters "home.bogus foouser foopasswd U".

If the command is successful then CtrlClnt returns 0 else it returns a value different from zero.

If the command is a query then the result will be redirected to stdout.

Part 23 - Server Shutdown

 

[Linux]

Under Linux XMail creates a file named XMail.pid located in /var/run that contains the PID of the main XMail thread.

By issuing the following command:

kill -INT `cat /var/run/XMail.pid`

a system administrator can initiate the shutdown process (this can take several seconds).

You can use the supplied xmail startup script to start/stop XMail:

xmail start / stop

 

[NT/2000/XP as a console service]

Under the NT console service (XMail --debug ...) you can hit Ctrl-C to initiate the shutdown process.

 

[NT/2000/XP as service]

Using the [Control Panel]=>[Services]=>[XMail] you can start and stop XMail.

 

[All Platforms]

XMail detects a shutdown condition by checking the presence of a file named ".shutdown" in the MailRoot irectory ( MAIL_ROOT ). You can initiate a XMail shutdown by creating ( or copying ) such a

file in this folder.

 

Part 24 - MkUsers.exe

This command line utility allows you to create user accounts (in a file called mailusers.tab) by providing a formatted list of users as a parameter (or by making a formatted text file).

 

The syntax of the list (or file) is:

domain;username;password;real-name;homepage[NEWLINE]

where the character '#' -if used for the fist column of a line- can be used to comment the entire line.

This utility can be also used to create a random number users, which is useful for me for testing the server performance.

 

The MkUsers command line parameters are ("{}" enclose the default value if any):

-a numusers = number of users to create in auto-mode

-d domain = domain name in auto-mode

-f inputFile = input file name {stdin}

-u username = radix user name in auto-mode

-r rootdir = mail root path {./}

-s mboxsize = mailbox maximum size {10000}

-i useridbase = base user id {1}

-m = create Maildir boxes (use this command ONLY for Unix!!)

-h = show this help

 

MkUsers creates the following file structure under the specified root directory: 

[Windows NT/2000/XP] Mailbox structure:

rootdir <dir>

mailusers.tab <file>

domains <dir>

domainXXX <dir>

userXXX <dir>

user.tab <file>

mailbox <dir>

...

...

 

[Unix ]  Maildir structure:

rootdir <dir>

mailusers.tab <file>

domains <dir>

domainXXX <dir>

userXXX <dir>

user.tab <file>

Maildir <dir>

tmp <dir>

new <dir>

cur <dir>

...

...

 

If a file called mailusers.tab already exist in the mail root path then MkUsers exits without overwriting the existing copy of the file mailusers.tab. This protects you from accidentaly overwriting your users file when playing inside the real MAIL_ROOT directory.

 

So if you want to setup the root directory (-r ...) as MAIL_ROOT then you must delete manually the existing file file first (you must know what you are doing).

If you setup the root directory (-r ...) as MAIL_ROOT then you MUST stop XMail before running MkUsers.

Existing files and directories will not be overwritten by MkUsers so you can keep your users database in the formatted text file (or generate it from a database dump for example) and then run MkUsers to create the XMail users structure.

 

Note: Remember that you have to add new domains in domains.tab file manually.

 

MkUsers is intended to be used as a bulk-mode utility, not to be used in order to create single users

because CtrlClnt.exe (or any other GUI/Web configuration utility) is far more appropriate.

Part 25 - Sendmail.exe

When building XMail an executable called sendmail.exe is also created. This is a replacement of the sendmail program used mostly on Unix systems. It use the XMail local mail delivery feature to send emails to the server.

 

The only supported sendmail options are (other options are simply ignored):

-f{mail from} = Set the sender of the email

-F{ext mail from} = Set the extended sender of the email

-t = Extract recipients from the "To:"/"Cc:"/"Bcc:" header tags

 

The syntax is:

sendmail [-t] [-f...] [-F...] [--input-file fname] [--xinput-file fname] [--rcpt-file fname] [--] recipient ...

 

The message content is read from the standard input and must be RFC compliant.

The following parameters are XMail extensions expected to be used with mailing lists managers (using

sendmail as a mail list exploder):

--input-file fname = takes the message from the specified file instead of from stdin (RFC format)

--xinput-file fname = takes the message from the specified file instead of from stdin (XMail format)

--rcpt-file fname = adds recipients listed in the specified file (list exploder)

 

Being RFC compliant means that the message MUST be formatted like this:

[Headers]

NewLine [CR-LF]

Body

 

So, suppose you have your message in the file "msg.txt", that you are "xmailuser@smartdomain" and

that you want to send this message to "user1@dom1" and "user2@dom2" then the syntax is:

sendmail -fxmailuser@smartdomain user1@dom1 user2@dom2 < msg.txt

or

sendmail -fxmailuser@smartdomain --input-file msg.txt user1@dom1 user2@dom2

Part 26 - Miscellaneous

 

[1]

To handle multiple POP3 domains the XMail server makes a reverse lookup of the IP address from which it receives the connection. Suppose that the reverse lookup will result in xxxx.yyyy.zzzz then XMail will check if xxxx.yyyy.zzzz is handled, then it'll check yyyy.zzzz and then zzzz.

 

The first (in the given order) that will be recognized by XMail will be the POP3 domain.

 

To avoid this behavior it is sufficient that the POP3 client supplies the entire email address as POP3 login username:

foo@foodomain.net => foo@foodomain.net

and not:

foo@foodomain.net => foo.

 

This enable XMail to handle multiple domains in cases where more nic-names are mapped over a single IP address.

 

To run finger queries you must specify:

foo@foodomain.net@foodomain.net

or as a general rule:

username@pop3domain@hostname

You can use the optional configuration variable "POP3Domain" to set the default domain for POP3 clients connections. This means that users of the "POP3Domain" can use only the name part of their email address as the POP3 login, while users of others hosted domains must use their entire email as the POP3 login.

 

[2]

a) REMEMBER TO REMOVE THE EXAMPLE ACCOUNT FROM the CTRLACCOUNTS.TAB FILE !

b) Use the ctrl.ipmap.tab file to restrict CTRL server access.

c) Use long password (mixed upper/lower case with digits) for the ctrlaccounts.tab file.

 

[3]

The main cause of bugs with XMail is due to a bad line termination of configuration files, so check that those files are correctly line terminated for your OS:

Linux uses the standard <CR> while M$ uses <CR><LF>.

 

[4]

If you get a bind error with Linux then you must comment pop3, smtp and finger entries in  /etc/inetd.conf.

 

[5]

Remember to setup the file CTRL.IPMAP.TAB to restrict the access to the IP addresses you use to administer remotely the XMail server.

 

[6]

If you have an heavy loaded server remember to setup the best number of SMAIL threads by specifying the "-Qn nthreads" option (you must do some tests to find the best value for your needs).

Also you can limit the number of SMTP, POP3 and CTRL service threads by specifying the options "-SX maxthreads", "-PX maxthreads" and "-CX maxthreads" on the command line.

 

[7]

If you have enabled logging remember to setup the "-Mr ndays" option. Depending on the traffic you get on your server this may be really useful by avoiding to work with very big log files (speeding up server performances).

 

[8]

If you're unable to start XMail even if you have read this document then compare your MailRoot directory tree with the one listed above. Many unzip tools do not restore empty directories by default.

 

[-]

Please report me errors about XMail itself and about this document.

If you have successfully build and run XMail please let me know at davidel@xmailserver.org, I don't want money  ;)

Part 27 - Known bugs

Version 0.1 (Alpha-1): 

0.1-001 Linux (FIXED)

SMail threads don't wake up upon a release semaphore issued by SMTP threads.

0.27-001 Windows

Using XMail in a network that uses MS Proxy Server 2.0 will cause XMail to fail sending UDP packets for DNS MX queries (due to a bug of WS2_32.DLL linked to MS Proxy 2.0). I don't know if greater versions of MS Proxy will fix this bug. To makes XMail work in such an environment you can use the "DefaultSMTPGateways" option in the SERVER.TAB file to use smart SMTP hosts. Or better, strip away MS Proxy server and setup a cheap PC running Linux and IP-Masquerading -that will cost exactly $0 and works great. Or use the "SmartDNSHost" option to redirect recursion queries to a smart DNS host which supports TCP and recursion.

Part 28 - Thanks

My mother Adelisa, to give me the light.

My cat Grace, for her patience - waiting for food while I'm coding.

All the open source community, to give me code and knowledge.

My company, Network Associates, to give me my wage.