PMSMTP v0.14b ============= PMSMTP.TXT - Copyright (c) 2007, Fred C. Macall Overview and System Requirements PMSMTP is designed to replace PMPOP's mail sending function in a DOS Packet Driver based Pegasus Mail (PMAIL) installation. PMSMTP complements PMPOP's capabilities by working with SMTP Mail Transfer Agent servers that may offer or impose an AUTH LOGIN authentication option or requirement. PMPOP doesn't seem to support the AUTH LOGIN SMTP extension. Therefore, PMSMTP should make Pegasus Mail useful with a group of SMTP servers that can't be accessed through PMPOP. As PMSMTP only sends mail, PMPOP or a comparable substitute also will be required in one's installation, for receiving mail. PMSMTP should run successfully on any IBM PC compatible machine that can run DOS, Pegasus Mail, and PMPOP. I run PMSMTP with PMAIL v3.3 on an 8088-based PC with DOS v3.3. And, on a '486-based PC, with various DOS versions. (Throughout this document, PMPOP is used as shorthand to refer to PDPMPOP.EXE, one of at least two versions of PMPOP. PDPMPOP.EXE is the version that is used in a DOS Packet Driver environment. During installation, it gets renamed PMPOP.EXE . Hence, my shorthand usage.) More About SMTP AUTH LOGIN SMTP AUTH LOGIN authentication is an SMTP extension that provides what amounts to a mail client login for sending mail. This is one means of authentication used by SMTP servers, which are ever more choosey about whose mail they'll relay. ESMTP servers that support AUTH LOGIN authentication advertise this in their response to the EHLO command. A mail client receiving an AUTH LOGIN advertisement may then expect to initiate a fruitful login exchange by issuing an AUTH LOGIN command. In turn, the ESMTP server issues prompts for a base64-encoded user ID and a base64-encoded password. Assuming that the server is satisfied with the user ID and password supplied, the SMTP session then proceeds in the traditional ways. Base64 encoding only slightly obscures the ID and password sent and won't keep them secret. However, for contacts with a dial-up ISP's SMTP server, the facilities between the answering modem and the SMTP server might be expected to be contained within the ISP's premises and, therefore, be secure. File SMTPAUTH.SES, included in PMSMTP14.ZIP, contains a session trace log type representation of an SMTP AUTH LOGIN exchange. (In this illustration, the lines carrying base64-encoded data include comments that begin with "base64". These comments decode the base64 data content illustrated and do not constitute part of the actual exchange data.) How It Works PMSMTP.EXE starts off by looking for its configuration file, PMSMTP.CFG, in the directory from which it has been loaded and, if necessary, in the "current DOS directory". Much of the configuration data is dedicated to the included WATTCP TCP/IP communications package. In particular, if PMSMTP version 0.14b finds my_ip=BOOTP or my_ip=DHCP specified in the configuration file, it then attempts to obtain its TCP/IP configuration from its BOOTP or DHCP server. With its configuration complete, PMSMTP checks its command line argument(s). If the first one is /? or if there are more than one, it displays its Usage message and terminates. For the record, this message reads: Usage: PMSMTP [/?] PMSMTP [base64 password data for SMTP AUTH LOGIN] If there is a lone command line argument that doesn't match /?, it is taken, without any further verification, as a base64-encoded password for SMTP AUTH LOGIN. Such a command line supplied password replaces any b64passw= value already obtained from the configuration file. PMSMTP then searches the maildir= specified mail directory for .MSG file(s). These are PMAIL's mail messages waiting to be sent. (These files are different from the .MSG files produced by Outlook Express.) If any are found, it attempts to contact the smtphost= specified mail server. By default, PMSMTP version 0.14b will attempt to contact the specified mail server via its well known TCP/IP port 25. This port number may be changed to, say, 587 by appending :587 to the smtphost= specified mail server's name, in PMSMTP.CFG. Once it has contacted the SMTP host, PMSMTP sends it an EHLO or HELO message or command. If both a b64usrid= mail user ID configuration value and a base64-encoded mail user password configuration or command line value have been specified, PMSMTP sends an EHLO command, requesting an Extended SMTP session. Otherwise, it sends a HELO command, requesting only a basic SMTP session. The full EHLO or HELO command includes an identifier consisting of: . . (Without those corner characters.) Upon receipt of a response accepting its EHLO command, PMSMTP searches the response for an AUTH LOGIN advertisement. If it finds one, PMSMTP attempts an AUTH LOGIN exchange to transfer its b64usrid= mail user ID configuration and base64-encoded mail user password values. PMSMTP reports some significant events on the display as it performs the SMTP session set up described above. It also indicates a successful SMTP session set up outcome by displaying the line: Ready. (d) Where d indicates the type of session set up achieved as follows: d Type of Session Set Up = ====================== 0 SMTP 1 ESMTP 3 ESMTP AUTH LOGIN PMSMTP expects PMAIL to be configured to deliver .MSG mail message files that look like: $$ "Sender's Real Name" T recipientsmailid@recipientsmailhost.dom C ccrecipientsmailid@ccrecipientsmailhost.dom B bcrecipientsmailid@bcrecipientsmailhost.dom From: "Sender's Real Name" To: recipientsmailid@recipientsmailhost.dom Date: . . . The part of the .MSG file ahead of the first blank line is known as the message's envelope data. The $$ line must come first and contain corner characters bracketing the sender's mail address, as shown. The rest of the envelope data identifies each of the message's To, Cc, and Bc recipient(s). With a separate line for each recipient. The part of the .MSG file after the first blank line is the message, itself. Once PMSMTP has successfully set up an SMTP or ESMTP session, it proceeds to read and send each .MSG mail file found in the maildir= specified mail directory as follows: First, it sends a MAIL FROM: command and one or more RCPT TO: commands based on the message's envelope data. Then it sends a DATA command and the message, itself. While sending a long message, PMSMTP version 0.14b presents a number on the display for each 28 KB buffer of message data sent. n, the most recent number presented, multiplied by 28 KB indicates the approximate length of the message transmitted to that point. Finally, PMSMTP sends a line containing only a period to the server, to indicate the end of the data. For the message file example above, PMSMTP would generate the following envelope commands: MAIL FROM: RCPT TO: RCPT TO: RCPT TO: (PMSMTP assumes that each message's entire envelope data will fit in a 28 KB buffer. With mail addresses averaging about 50 characters long, that should allow for up to about 500 recipients for a single message. I do not know whether PMAIL is even capable of generating a message with a 28 KB long envelope. PMSMTP version 0.14b no longer requires PMAIL to keep the message data from containing any line(s) that contain only a period. Rather, it doubles any period(s) found at the very beginning of a line. In turn, the SMTP mail server is expected to restore any doubled periods found, at the beginning of a line, to a single period.) For each SMTP command and the message data block that it sends, PMSMTP expects the particular SMTP Reply Code that indicates success for that operation, from the server. (For RCPT TO: commands, PMSMTP expects either Reply Code 250 or 251.) While the expected Reply Codes are obtained, the process continues. After successfully sending each .MSG message file, PMSMTP attempts to rename the file with a suffix of .MS$. If the rename call succeeds, PMSMTP proceeds to search for another .MSG mail file to send, in a continuation of the already established SMTP session. Once all of the .MSG file(s) have been renamed or an unexpected response has been obtained, PMSMTP sends an SMTP QUIT command, reports to the display on what it has accomplished, and terminates. Installation and Configuration I think there may be some fairly easy ways to arrange for running PMSMTP from PMAIL's "Send all messages" menu entry. However, I haven't felt the need to bother with that. So, these instructions lead you toward running PMSMTP from outside of PMAIL. Also, I am assuming that you have already installed Pegasus Mail and PMPOP. If you need PMSMTP, your ability to send mail without it may be little or none. However, you should already be fully able to receive your mail from your POP3 server via PMPOP. 1. PKUNZIP PMSMTP14.ZIP into an empty directory. 2. Copy PMSMTP.EXE into the directory where you keep your other Pegasus Mail programs. If you are upgrading an existing PMSMTP installation, your existing PMSMTP.CFG configuration file will likely serve without change. If you are installing PMSMTP for the first time, also copy PMSMTP.CFG into the directory where you keep your other Pegasus Mail programs. 3. If necessary, adjust your Pegasus Mail User Gateway Definition, through the PMCONFIG program, to deliver the mail message file format described in the How It Works section, above. In particular, the entry for Filename format must end in: .MSG to give your mail message file names the .MSG extension. The entry for Reply address format may be: "~p" <~n> In that case, the PMUSER environment variable setting or PMAIL sign on user name response must include one's whole e-mail address, to yield the $$ line expected. Finally, the entry for Simple message headers must be: 'Glue' headers to specify the mail message file format described above. These settings are part of the set of settings that PMPOP.TXT suggests for use with PMPOP. UDG.TXT provides additional information about these things. 4. If necessary, edit, or tailor, PMSMTP.CFG with an ASCII text editor that confines the non-text or format control information that it adds to nothing more than new line sequences. In a new PMSMTP installation, you must tailor PMSMTP.CFG for your own case. At the very least, that will mean supplying your own values for b64usrid=, hostname=, and domainslist=. Unless your mail installation happens to be a lot like mine, you also will need to supply appropriate values for maildir= and smtphost=. If you don't mind putting your base64-encoded password into the same file, you may want to specify b64passw=, too. Otherwise, you'll state it on PMSMTP's command line when necessary. Finally, if your installation doesn't support BOOTP for TCP/IP configuration, you'll also need to specify a value for my_ip= . With PMSMTP version 0.14b, that might be my_ip=DHCP. Otherwise, if your installation doesn't support DHCP for TCP/IP configuration, you also will need to specify netmask=, gateway=, and nameserver= . PMSMTP.CFG contains lots of comments describing the values needed. Wrapping Your PMSMTP Command in a .BAT File Specifying both b64usrid= and b64passw= in PMSMTP.CFG will prevent you from running PMSMTP with SMTP AUTH LOGIN authentication disabled, if and when that is appropriate. Also, it leaves all your secret mail identity "eggs" in a single basket. To avoid these problems, you should leave b64passw= out of your PMSMTP.CFG file and state your base64-encoded password on PMSMTP's command line when necessary. Another alternative is to wrap the PMSMTP command(s) you issue frequently in one or more .BAT file(s). Specifying your base64-encoded password on the PMSMTP command line in such a .BAT file leaves it vulnerable to anyone who can get physical access to your system. But, that will allow you to separate it, in various ways, from the rest of your mail installation's configuration. Making it harder for a snooper to find. File SENDMAIL.BAT, included in PMSMTP14.ZIP, provides an example showing how to invoke PMSMTP with a base64-encoded password on the command line. In that example, the PMSMTP command line is included in a SCRIPT command. SCRIPT is available at ftp://ftp.simtel.net/pub/simtelnet/msdos/screen/script11.zip . It runs the PMSMTP command and appends its output to a log file at the same time as it is presented to the display! I've now changed SCRIPT to @SCRIPT, in the example, to keep the PMSMTP command, with its secret, from being displayed when SENDMAIL runs. If you want to use SENDMAIL.BAT but don't want a log file or don't have SCRIPT, simply delete everything before PMSMTP from the @SCRIPT command's line. Either way, you'll also need to change that base64-encoded password to your own, of course. If you don't want copies of your mail saved in .MS$ files, you can add a DEL *.MS$ command to your own SENDMAIL.BAT file. By now, you may be wondering how to base64-encode your mail ID and password. Base64-Encoding PMAIL v3.3, at least (I am not experienced with earlier versions), contains base64-encoding code within its MIME support. MIME-encoding is simply base64-encoding with extra rules about line lengths and formats. So, you can use Pegasus Mail's MIME support to base64-encode your mail user ID and password. You simply enter each of those items into a separate file and mail them as MIME attachments to a note to yourself. You may view the resulting .MSG file with a text editor. Or, use Pegasus Mail's "Display the message anyway" menu entry, on the received note's Binary data Sections, to view the MIME-encoded files. The data you want will be at the end of the displayed message. The encoded data will consist entirely of displayable text characters. (That's the whole purpose of MIME encoding.) An ID or password value n characters long will be encoded into exactly 4 * INT((n + 2)/3) characters. To enter your mail user ID into a file named, say, USERID, command: COPY CON USERID at your DOS system's CONsole. Then, type your mail user ID and end with Ctrl-Z and Enter. (For Ctrl-Z, hold a Ctrl key down while typing the Z key.) Use the TYPE and DIR commands to verify that your ID is right and that there is nothing extra (like a new line sequence) in the file. (For a seven character ID, DIR should report USERID's size as exactly 7.) Don't neglect the case or shift of your ID's letter(s). If you notice a mistake while typing your ID, simply end with Ctrl-Z and Enter. Then, DEL USERID and start over. Use the same technique to enter your mail password into another file named PASSWD. With your USERID and PASSWD files ready, command PMAIL and take its "Send a mail message" and "Compose a new message" menu entries. Then, use F9 - More options, to verify that MIME features? is set to Y(es). Next, start a message to yourself and use F7 - File attachments. For each file to be encoded (USERID and PASSWD), use the Ins key to start an attachment entry and enter the file's name. For File type, use Binary. For Encoding, use Basic MIME. To finish, commit your attachments and complete and commit your message. You will be able to read your base64-encoded data from the resulting message as explained above. In the interest of security, remember to delete all files containing un-encoded or even encoded versions of your password, including mail and mail log files, developed in the course of this exercise. History I make both DosLynx and PMSMTP using a single WATTCP TCP/IP software library. As a result, most of the changes made in PMSMTP, between versions 0.12b and 0.14b, stem from improvements made in that library. These improvements have been described in many of the history.txt documents accompanying my DosLynx releases. If you want to know all the gory details, search for WATTCP and/or TCP/IP, in those documents. The most recent of these is the history.txt document for DosLynx v0.33b. Presently, it may be found at: http://users.ohiohills.com/fmacall/history.txt . In its introduction, that history.txt document tells where all of my previous DosLynx history.txt documents may be found. The history.txt document for DosLynx v0.25b may be of particular interest to PMSMTP users. It provides background on the DHCP support which is new for PMSMTP, in its present version 0.14b. Three other changes, which (so far) are specific to PMSMTP v0.14b, are as follows: In the fall of 2006, some ISPs in Europe and the Middle East were reported changing their SMTP servers, for mail origination, from listening on TCP/IP port 25 to listening on TCP/IP port 587. I thank Niels Oestergaard for informing me of this development. To accommodate the possibility that your SMTP server will be listening on TCP/IP port 587, or some other, I've made this configurable. You add :portnumber to the end of your smtphost= configuration, in PMSMTP.CFG, if it isn't using the traditional port 25. At PMSMTP v0.14b's start up, a new message will report on the SMTP server TCP/IP port being contacted. PMSMTP previously neglected the need, in SMTP, for providing transparency for period(s) occurring at the very beginning of mail message line(s). I had used wishful thinking to suppose that PMAIL must be taking care of this. I thank Mirek Flesko, http://flesko.cz , for informing me of his impression of this issue, in PMSMTP. This need is described in RFC 2821, Simple Mail Transfer Protocol, section 4.5.2, Transparency. That section also describes a procedure, for leading period doubling, to be performed by Mail Transfer Agents such as PMSMTP. While that procedure wasn't being used, a mail message line containing only a single period would trigger the truncation of its message at that point! RFC 2821's leading period doubling procedure has now been incorporated in PMSMTP version 0.14b. Mirek also informed me that his blind friend didn't find PMSMTP's progress indication very helpful when sending real long mails. To be of much help, PMSMTP's progress indicating periods had to be counted, by anyone not able to see them all at a glance. I think I've improved on this, in PMSMTP v0.14b. Though, perhaps not as much as Mirek would like. Instead of displaying only a period, for each processed 28 KB buffer full of a message's data, PMSMTP v0.14b will now display each buffer's number. Like this: 1 2 3 4 5 6 7 8 9 10 11 12 . . . So, it will be sufficient to know the most recent buffer's number, to know where a long message's transmission stands. Copyright Notices PMSMTP.EXE v0.14b and the libraries, materials, and tools used to make it contain the following Copyright notices: PMSMTP.EXE - Copyright (c) 2007, Fred C. Macall Copyright (c) 1994, University of Kansas, All Rights Reserved Written by and COPYRIGHT (c)1993 to Quentin Smart Copyright (c) 1990, 1991, 1992, 1993 Erick Engelke Borland C++ - Copyright 1991 Borland Intl. Copyright (C) 1990 by Marty Del Vecchio LZEXE.EXE Version 0.91 (c) 1989 Fabrice BELLARD Neither PMSMTP.EXE v0.14b nor any of the rest of the contents of the PMSMTP14.ZIP package may be copied, except by individuals for their own personal evaluation or use in an e-mail installation based on Pegasus Mail. Permission for copying for any other purpose(s) must be arranged in advance with the package's author, Fred C. Macall. Disclaimer This software is published 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. Fred C. Macall 1019 Pennfield Road Cleveland Heights, Ohio, 44121, U.S.A. (216) 382-3415 (For e-mail contact, please display FCMEMADR.GIF .) 6 January 2007