
                        FDSMTPOP v. 0.34
             Yury Semenov   <yury@zipper.paco.net>

FDSMTPOP v. 0.33 patch 1 by Paolo Patruno <p.patruno@iperbole.bologna.it>

At first: Archive FDSMTPOP.ZIP which contain GPL'ed implementation of
SMTP and POP3 mail exchange protocols is accesible at

             http://zipper.paco.net/~yury/FREEDOS/fdsmtpop034.zip

I'm sure that under DOS name of received file will be FDSMTPOP.ZIP without 034
suffix. Suffix allow you to select last version ;-).

This implementation uses WATTCP library and have been tested with such
PPP drivers as EtherPPP and DOSPPP.


  NEWS:
        Version 0.34: Some bugs fixed, including: smtp before pop3 now
        works without hanging :), according with rfc 821, 822 every line
        now terminated with CRLF. Adding "Sender:" field to message
        header and removing from it fields "Bcc:" and "Resent-bcc:".
        Version 0.33p1:
        Patch by Paolo Patruno, accepted partially (+ - accepted)
         +  correct testing of +OK POP3 response
         +  implemented C and B fields in pmail header (Pmail)
         ?  manage BCC  field in header fields (deleted if present) (Pmail)
             YS: rewritten for general case
         -  forced FROM field in header fields according with -f (Pmail)
             YS: according with rfc0822 FROM and from fields are the same.
             On other hand address used with -f option must be added
             to "Sender:" field - implemented in v. 0.34
         +  some more log and error condition on smtp polling
        Version 0.33:
        Incorrect 334 esmtp server responce processing fixed.
        Version 0.32:
        Many and many bugs of v.0.30 and 0.31 have been fixed
        (like wrong processing of "250-" ESMTP responces and even \r
        character in CR/LF line terminator, last error was appeared in
        version 0.31, sorry for troubles :)
        New command line parameter "esmtp" defined. It is equivalent of
        -E switch. So now there are parameters "smtp", "esmtp" and "pop3".
        Version 0.30:
        Some ESMTP features are implemented: ESMTP handshaking and
        CRAM-MD5 authentication (derived from the RSA Data Security, Inc.
        MD5 Message-Digest Algorithm). New switches: -E to force using
        of ESMTP ehlo, and -e esmtpname:esmtpassw for using by CRAM-MD5.
        No neccessety to use both swithes: -e alone implies ESMTP mode...
        Version 0.24:
        Finally implemented some variations on Joerg Andlauer correction 
        of scanning pop3 server responce :).
        Version 0.23:
        Some bugs were fixed, also now you may set reverse sequence of
        requests for services: at first for pop3 then to smtp. Services
        will be invoced in sequence of its occurance in configuration
        string.
        Version 0.21:
        Bug fixed - now FDSMTPOP put parameter (address) of MAIL FROM:
        and RCPT TO: commands into <> pair. Some SMTP servers does not
        requires it but some - requires.
        In any case - there were no any complains ;-).
        Now it is possible to work not only with sendmail at remote site,
        but even with qmail. Special feature for qmail was implemented -
        to begin send message body not only after 354 SMTP responce, but
        even after 250 responce - this is usual way of qmail behaviour...
        Some new exit errorlevels, error/log messages and command line
        switches have been added; *.MSG now is only default extention for
        incoming mail so user can choose more preferable extention...
        Also (feature from my personal dreams :) WATTCP DNS functions were
        extended and now FDSMTPOP can ask DNS server for MX's of addressee
        and then send mail to correspondent MX host (not via ISP sendmail).
        BTW: see APPENDIX below for more discussion on subject...

  HISTORY: 
        Version 0.12 - now possibility of infinite data waiting is excluded.
        Parameter sock_delay from WATTCP.CFG is maximal waiting time for
        connection, data etc... I don't sure that now code is very beauty, but
        it works, and it seems that this version is usable for BBS'es and other
        automatically controlled environments...
        Also some small changes in error messages and mail boxes handling have
        been made...

        In version 0.11 I've fixed two bugs: pop3 list scanning bug, and
        not very correct protocol switching in some specific cases...
        Now FDSMTPOP more convenient for Pegasus Mail users - thanks to
        Ken Bowley for detailed reports... Now -f argument is have more
        priority then sender address from control file or control header.
        Now FDSMTPOP user can define separate SMTP and POP3 hosts. Except
        -l mode (leave mail on server) there are 2 new modes -n (retrieve
        new mial) and -k (kill old mail). Also everybody may control FDSMTPOP
        verbose level using -v switch.



Sorry - this is a very small description of this program - see sources and
RFC-821 and RFC-1081 for more details. I don't sure that this program is
neccessary for anybody ;-), but I've wrote this program during last weekend
and this is a small gift for myself for my birthday ;-). Also I see some
unsatisfactory features of such programs as POPMAIL for DOS or PMPOP.
Yes, I don't sure that selected program name FDSMTPOP is very good ;-).
This program is implementation of SMTP/POP3 client for DOS and uses WATTCP
library. It supports mail queues styles used by such programs as PMPOP,
FreeEmacs and (still popular in xUSSR with Demos Mail editor:) UUPC (see
remark below). So FDSMTPOP can save inbound messages into separate files in
specified directories or into uucp style mail box, and also understand 3
formats of outbound message:

 1. UUPC sendmail style (default):

          +--------------------------
          |send-mail                   (you may also use name of sender here)
          |user1@domain1               \  Destination address list
          |user2@domain2               /
          |...
          |<<NULL>>                    (literaly:)
          |...Message body...

 2. Pegasus Mail style:

          +--------------------------
          |$$ from_addr
          |T user1@domain1             \  Destination address list
          |T user2@domain2             /
          |C user3@domain3             /
          |B user4@domain4             /
          |...
          |                               Empty line
          |...Message body...

REMARK: before transmitting now FDSMTPOP strip () - comments in from_addr
        field and remove BCC: field in header
        if -f arg is present from_addr and FROM:from_addr in header
        will be modified

 3. FreeEmacs *.wrk file:

          +--------------------------
          |host_addr
          |from_addr
          |user1@domain1               \  Destination address list
          |user2@domain2               /
          |...
          +--------------------------

Command line format and switches:

    FDSMTPOP  <modes> <switches and parameters> +configfile

You may move some or all modes and switches (except -? switch) into
configfile.

    <modes>  - optional - default mode is 'smtp'
               valid modes and combinations: 'smtp', 'pop3', 'smtp pop3'

    <switches>

       -?                     - print help message

       -h host:port:pport     - port and pport are optional decimal SMTP and
                                POP3 TCP ports.
       -H host:port           - define separate POP3 host (and port)

       -d domain              - your domain, will be used in HELO command

       -f from                - from user, will be used in MAIL FROM: command

       -l                     - leave received messages on POP3 server
       -n                     - retrieve new mail
       -k                     - kill old mail

       -qu path               - UUPC outbound queue
       -qp path               - Pegasus Mail outboud queue
       -qe path               - FreeEmacs outbound queue

       -m  path_or_filename   - indound mail directory or mail box

       -p  user:password      - POP3 user and password
       -e  user:password      - ESMTP user and password

       -i  ext                - Filename extention for incoming mail; will be
                                used instead default ".msg"

       -D                     - Force SMTP mail delivering  via MX hosts
       -E                     - Force ESMTP mode

       -v  verbose_level      -  0  Silent
                                 1  Logo
                                 2  Error Messages
                                 4  Operation status              <-- default
                                 6  Show commands for server
                                 8  Show server responses
                                10  Show lists and message texts

Some remarks:

  + I recomend to store -p login parameters into configfile.

  + I include only compiled by TC 2.0 (!) WATTCPSM.LIB to this archive, you
    can find same library compiled with BCC 3.11 in Ken Yap's HTGET101.ZIP,
    or simply get sources from ftp://ftp-ns.rutgers.edu/pub/pc/wattcp/ ...

  + Use environment variable FDSMTPOPLOG to enable log and specify log
    filename.

  + Successfully sent outboud messages will be deleted.
  + Undelivered messages will be leaved in outbound queue.
  + Messages delivered to some recepients but undelivered to other will be
    leaved in outbound queue directory but with set attributes Hidden and
    ReadOnly. Error message will be written to logfile.

  + Remark for UUPC users, which want to still use Demos Mail (or other
    UUPC editors) under DOS but using PPP ISP accounts instead uucp:

    At first you must install such driver as EtherPPP or DOSPPP. Then you
    must run 'FDSMTPOP smtp pop3' instead UUCICO. You may still use usual
    editor but you must replace SENDMAIL program (dmail call 'sendmail -l'
    with redirected stdin stream) with your own one which simply save data
    from stdin stream into file located in outbound mail queue directory.
    If you have only one user defined on your system then there are no
    problems: you must specify for FDSMTPOP to receive mail into his mail
    box. Else it is better to receive messages into separate files in
    inbound mail directory, and replace UUXQT with special small tosser which
    will parse headers of incoming messages and append every message to
    correspondent user mail box. Don't forget add to mailbox string
    "From whatever you like...\n" before message body.

Exit codes used during startup termination:

     0                OK
     1                "Hostname is not defined"
     2                "Can't resolve SMTP/POP3 host address"
     3                "TCP error"
     4                "Outbound mail queue directory is not specified"
     5                "Inbound mail directory is not specified"
     6                "Sorry, now direct SMTP access is not implemented"
     7                "POP3 server address is not specified"
    -1                Some as it seems to me impossible cases...

Error bit flags which FDSMTPOP set during mail sessions:

     8                TCP timeout
    16                POP3 server refuse call
    32                Bad POP3 account data
    64                Can't establish SMTP session or nonfatal error
                      during SMTP session


APPENDIX. Extending WATTCP resolve() call.

Now new source file DNS.C have been added to FDSMTPOP distribution.
This module is devived from UDP_DOM.C. Now DNS functions supports either
UDP or TCP requests, MX requests now also are supported. List of some
new functions:

extern struct useek *getmxlist(char *name);
extern struct mxrr *getmxanswer(struct useek *u,int anum);
extern longword getmxip(struct useek *u, char *dom);
extern longword procmxlist(char *domname, struct useek *u, word minpref, 
                              FILE *log);
extern word preference;

Now promised discussion ;-): I understand that DNS MX request support
implementation is not complete. Today I don't know what to do with CC
in MX delivered mail and simply try to send them to same MX host as
original message. Everything will work good only if 

  1) there are no CC at all
  2) all CC's are desined to same host (more generally: to same MX host)
     as original message.

If you want more smart behaviour - wait next versions - today I don't know
how to implement separate delivering for every CC...
In fact you can use CC just now but then you must have special program
(router in FTN terms, it seems that Pegasus Mail also do something like)
which will put separate copies of message to outbound queue for every CC
and then call FDSMTPOP.

BTW: I don't sure that this is very critical point - probably usually it is
better send mail via ISP mail system, sometimes when you want see by own eyes
process of delivering of your mail you really may prepare separate copy of
message...

See sources for more detail...
This DNS implementation is based on RFC-883, RFC-973, RFC-974.


	15/12/01      Yury Semenov   <yury@zipper.paco.net>


