Liam Den Son >|< Nos End Mail
Description
This is a small, simple, modular dial-on-demand mail server that can be used within the
Cygwin
environment for Windows. This mail server, could in principle, work under any Unix variant (though
not tested), since the design uses Unix-based tools and ideas.
This project came into existence for several reasons, the most notable is
that a large motor yacht required a replacement for their 3rd party Windows
based mail server solution that was used by the owner, ship's captain,
and crew. The Windows solution was proving to be too complicated to administer
with multiple access providers world-wide and their three means of connectivity:
land-line, GSM, and SatCom.
Replacing the Windows 2000 server with a Linux box was not an option, since it
provided other services to the yacht. Alternative 3rd party Windows based mail
solutions were researched, but appeared to be no better than the existing solution.
A Unix-like solution that could be built in a hurry seemed like an idea to try and
the Cygwin environment provided
a good basis from which to start. However, most of the popular Unix mail solutions
such as
Sendmail,
Postfix,
Qmail,
Exim, and the
Courier Mail Server
have not been ported to the
Cygwin
environment and would probably take more time port than was available.
This meant either finding or writing the necessary pieces for a solution.
A solution would entail several identifiable pieces: a dialler, a basic SMTP server,
a complete POP3 server, a mail transport agent, and a scripting language to bring all the
pieces together.
The solution outlined here has a simple modular design that uses existing
software tools from a variety of sources: the
Cygwin environment provides most of
the framework and "glue" with scripting tools like Bash,
Perl,
Python, or
Ruby being readily available;
Windows 2000's rasdial, which is suitable for use in scripts, solves the dialler problem (thankfully);
a modified fetchmail for a mail transport agent;
Cygwin provides an inetd
super-server, that can run as a Windows 2000 service, combined with
small smtpd & pop3d inetd servers which provide
a mail queue and local mail delivery & retrieval facilities.
The smtpd server supports RFC
2821
&
2882
and the pop3d server supports RFC
1939,
1957
&
2449.
Both the smtpd and pop3d work fine with
fetchmail and
popular mail clients such as Netscape,
Mozilla,
Opera, and Outlook Express.
The smtpd and pop3d
share a common configuration
file, mail.cfg, that can be managed with mailcfg.pl.
Both servers implement mail boxes similar to, but not entirely the same as,
maildirs as developed and
used by Qmail and the
Courier Mail Server.
The outbound mail queue is itself a mail drop box that can be accessed by
the modified fetchmail via the
pop3d server, so as to forward mail to an upstream SMTP server. The simple
modifications to fetchmail removed
the burden of having to write a full smtpd gateway and shortened development
time. The diagram above shows the logical structure and data flow of the
principal interacting pieces.
I've recently had some feedback from
Ricardo d'Angelo at astrazeneca dot com
who explained to me how he intends to use A Mail Server. His firm has
a web application for their sales representatives to help organise promotional events, which also
involves an approval workflow mechanism. Ricardo writes:
We designed the training in such a way that the different roles are appropriately played to create
a realistic environment. As our trainer needs to travel across the country we implemented a network
of laptops with wireless adapters, and the only piece that was missing was to mimic the mail
server, to implement the notification piece that is an essential part of the application.
Download
Build
The setting up of a build environment can be a time consuming process
and requires some understanding of Unix, which the
Cygwin environment emulates by providing the
necessary APIs and ported tools.
My development environment already existed for assorted other projects prior to this one and
so I will NOT provide support, help, explanations, tips, tricks, etc. on how to
setup Cygwin for the purpose of building my software for this project. However, I can tell you
that you will require the following:
-
-
To deploy A Mail Server, you'll require the Cygwin base install including
binutils, inetutils, less, and perl at a minimum. The Cygwin supplied version
of fetchmail is of no use.
To build A Mail Server binaries for smtpd, pop3d, and
fetchmail from scratch,
you'll also require a build environment with bison or yacc, flex, gcc, make, openssl
libraries & development headers, and patch all from the
Cygwin distribution.
-

-
To build the modified fetchmail binary, you'll require the fetchmail-5.9.13
source distribution. You'll need to apply the fetchmail-5.9.13.patch included
with my source distribution and build fetchmail
with SSL support. My patch has been
submitted to the author of fetchmail and may appear in a future release (I hope).
Please read the fetchmail INSTALL document on how to configure and build the binary.
- LibSnert
- To build A Mail Server binaries for smtpd and pop3d,
you'll have to build my development support library to link with.
Deploy
Having just recently deployed
A Mail Server solution on a motor yacht, the following documents
those steps involved.
Login to Windows 2000 Pro as the Administrator. Note that Windows XP Pro should work, though the
location of things may have changed (unknown);
Windows XP Home Edition is a cripple and not recommended for anything.
Install the base Cygwin environment
and make sure to include binutils, cygrunsrv, inetutils, less, and perl packages.
On Windows 2000, you need to update the system wide environment variables found via:
Control Panel
> System
> Advanced
> Environment Variables
- Add the variable: CYGWIN=ntsec
- Prefix the PATH variable with: c:\cygwin\bin;
Also for Windows 2000, in order for the inetd service to run correctly
you'll need to modify the Local Security Policy found via:
Control Panel
> Administrative Tools
> Local Security Policy
> Local Policies
> User Rights Assignment
For each of the following, add the Administrators group to the list of names:
- Act as part of operating system
- Increase quotas
- Logon as service
- Replace process level token
Note that Windows XP Home Edition does NOT support the ability to change
Local Security Policy in this manner, if at all.
Modify the properties of the Cygwin shortcut so that the Target field says this:
C:\cygwin\bin\bash.exe --login -i
Now using the modified Cygwin shortcut, open the Cygwin shell window and unpack the
archive downloaded
from this web site. You might want to view the manifest.txt
to see where files will be unpacked relative to the Cygwin root directory.
$ tar -C c:/cygwin/ -xzpvf ams102.tgz
The inetutils package from Cygwin does not provide a traditional services file.
It is unclear whether this file is required or not with the Cygwin version of inetd. A
sample has been provided and should be renamed if required:
$ mv /etc/services.sample /etc/services
Next the file /etc/inetd.conf should either be replaced with the sample
/etc/inetd.conf.sample or the following two lines added to the existing one:
smtp stream tcp nowait Administrator /cygdrive/c/cygwin/usr/local/sbin/smtpd smtpd
pop3 stream tcp nowait Administrator /cygdrive/c/cygwin/usr/local/sbin/pop3d pop3d
Enter the following two commands to install and start the inetd service under Windows 2000:
$ cygrunsrv -I inetd -d 'Cygwin Inetd' -p /usr/sbin/inetd -a '-d' -e CYGWIN="tty ntsec"
$ cygrunsrv -S inetd
Use the following script to help you configure your mail server accounts:
$ /usr/local/sbin/mailcfg.pl
Use the following script to help you configure your mail transport for incoming
and outgoing email with a remote mail server:
$ /usr/local/sbin/mailtransportcfg.pl
Configure and test any new Dial-Up Networking entries. The mailcheck.pl
script then needs to be configured for each entry you intend to use. The simplest
way to do this is using the following configure script:
$ /usr/local/sbin/mailcheckcfg.pl
Please note that the "Show terminal window" option for Dial-Up Networking connections
must NOT be on, otherwise the mailcheck.pl script will fail.
Rather than go to the trouble to setup Cygwin cron, use the Windows 2000
Scheduler to invoke the following script on a schedule of your choosing:
c:\cygwin\bin\perl.exe c:\cygwin\usr\local\bin\mailcheck.pl
Done. Of course, test the system to see that mail clients can send & receive email,
that mail gets delievered to local mail boxes and/or queued in the outbound mail box. Then
test that mail is sent to and received from the remote server. Send mail from a remote
account to the local system, reply to this email to see if it makes the round trip
successfully.
Note that the set up of mail client software is outside the scope of this document, but in general a mail
client, such as Mozilla, Opera, or Outlook Express, will require the IP address of the incoming POP3
server and the outgoing SMTP server, a user mail box name and a password. Since the POP3 and SMTP
server here are on the same machine, the values entered should be the same.
Administration
The hardest part of this mail server is the setup & security. Once that is completed,
maintaining the system is simply a matter of using one or more of the following configure
scripts:
- /usr/local/sbin/mailcfg.pl [cfg-file]
- Used to specify local domains names accepted by the server, define user mail boxes &
their passwords, define email address mappings to mail boxes, and miscellaneous options.
- /usr/local/sbin/mailtransportcfg.pl (not yet written)
-
Defines the mail transport accounts. This is by far the most complex task.
- /usr/local/sbin/mailcheckcfg.pl
-
In the case of a mobile system, such as on a motor yacht, this script allows you
to manage dial-up connections, their associated user name & passwords, and
to select which one to use at any one time.
License
Non-commercial redistribution and use of the original source
distribution, without modification, is permitted provided you retain
this notice, the author's copyright notice, and any & all links
within the source distribution back to this license and disclaimer below.
Commercial use, in the role of "end-user" for internal business
operations, of the original source distribution, without modification,
is permitted provided you retain this notice, the author's copyright
notice above, and any & all links within the source distribution and/or derived
binaries back to this license and disclaimer below.
Commercial redistribution (including but not limited to bundling,
collections, resale) of the original source distribution and/or derived
binaries, with or without modification, is permitted provided you retain
this notice, the author's copyright notice, and any & all links
within the source distribution and/or derived binaries back to this license
and disclaimer below.
In all cases a monetary donation and/or Amazon
wishlist gifts to the author are welcomed, but not required, for the continued
encouragment, moral support, and ego pumping needed to work in foriegn non-english
speaking lands.
Disclaimer
THIS SOFTWARE IS PROVIDE "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO WAY SHALL THE
AUTHOR OR LICENSEE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
Support
Support is only provided for the author's original source distribution.
Free support is limited, based on the author's availability, though
enhancements requests and problem reports are welcome.
Copyright 2002, 2003 by
Anthony C Howe
All rights reserved.
[an error occurred while processing this directive]
pieces of eight since 24 August 2002
|