                      Qmail MailDir2Smtp Shell Scripts
                                Version 1.7
                               David Summers
                        david@summersoft.fay.ar.us
          ftp://summersoft.fay.ar.us:/pub/qmail/qmail-smtp-1.7.tar.gz

LEGAL MUMBO JUMBO:
These files are in the public domain.  If you improve on them I would appreciate
receiving the improvements.  I can not garuntee that these will work for you. 
I can not be held responsible if this does anything bad to you or your computer.

Here is a set of scripts which I find usefully exploits the maildir2smtp
capabilities of QMAIL.

My setup has a Solaris 2.5 server and Linux clients.  Each client uses Linux
diald to establish a PPP connection to the network when the smtpcall script is
called from crontab.  This script telnets to the server, logs in, and connects
with the "qsmtpd" server which validates the login, without transmitting the 
password in the clear, similarly to the simple idea from RFC 1725 (APOP), and then
blasts the mail across the network to the client smtp port.  Since the PPP
connection is established automatically by diald whenever there is network
traffic from the client, qmail can send e-mail any time from the client to the
server.

I haven't investigated the ability to queue mail from the client to the server
but if you wanted to do that then just have the client establish the reverse
connection; these scripts should help.

Pre-requisites for both client and server:
The "perl-5(.003)" package.
The "md5sum" program (can be found in GNU textutils).

The file names and descriptions follow:

Name         Description
=====        ============
smtpcall     Call a remote site.
smtpmkdir    Create a /var/spool/qmail spool directory for a user.
smtpq        List the number and names of files in the /var/spool/qmail queues.
qsmtpd       Server process to receive a remote call and send the queued files.


Here is the sequence of setup and operation.

On the server side:

1. Set up /usr/local/bin/qsmtpd as a server process
   (maybe in /etc/inetd.conf??? Haven't tried inetd.conf yet).
2. Set up USER in the /etc/qmail/control/passwords file with home directory of
   /var/spool/qmail/USER like so:
   incoming.dom.ain:USER:SecretPassword:/Path/To/Maildir
3. smtpmkdir USER
4. Set up /var/qmail/virtualdomains to point to USER for that host.
5. Stop and Start qmail to make new virtualdomains active.

On the client side:

o. Set up /var/qmail/control/passwords to be only readable by root.
   The format is: host:USER:password:/Path/To/Maildir
o. Set up crontab for root to start up /usr/local/bin/smtpcall periodically:
   30 * * * * /usr/local/bin/smtpcall host port USER


CHANGES:
1997/03/17 Version 1.7 - Fixed the incredibly stupid "security-by-obscurity"
                         problem where any user on the server that could read
                         the password file could have someone else's e-mail
                         transferred to him. Now uses an extension of the
                         /etc/qmail/control/passwords file that has the Maildir
                         added.
1996/12/16 Version 1.6 - Fixed duplicate e-mail problem.
                         Fixed defunct(zombie) process problem.
                         Added e-mail logging to client side.
1996/12/10 Version 1.5 - Fixed timeouts to wait forever after initial handshake
                         so that big files can be transferred and duplicate e-mail
                         doesn't get sent.
1996/12/07 Version 1.4 - Moved smtpsend to qsmtpd and re-wrote in perl.
                         Fixed qsmtpd and smtpcall to use RFC-1725 (APOP) MD5SUM
                            to validate the user and password so the password
                            doesn't have to be transferred in the clear.
                         Got rid of smtppass (now part of smtpcall perl script).
1996/11/24 Version 1.3 - Added logging to smtpsend.
1996/11/24 Version 1.2 - Fixed smtpsend to act as login server.
1996/09/01 Version 1.1 - Fixed smtppass to use parameters $1 $2 correctly.
1996/09/01 Version 1.0 - Initial Version.
