Email on FreeDOS in 2023 — Pegasus Mail

Pegasus Mail banner

Back in the 1990s, when email first became a thing for the wider community, for a lot of us in the non-UNIX world, Pegasus Mail was the first email program we used. If you were in UNIX-land, it was pine, elm and mutt and if you were on MSDOS or Windows up to Windows 98, it was quite possibly Pegasus Mail.

It still exists and is still being developed. (https://www.pmail.com/) The current version for Windows (including 10) is version 4.80 and is at https://download-us.pmail.com/w32-480.exe.

The last DOS version I know of is 3.50. The pmail (as we’ll call it) architecture is such that you can think of it as 3 programs.

  1. An agent to pull the email off the server.
  2. A program to manage and edit email — read in the results of the pull, write new emails ready to go out, manage them into folders, handle attachments and so on.
  3. An agent to send the email.

This means that if you (by which I mean not me) are able to create the needed agents. pmail 3.50 can still profitably be used for step 2.

Fred Macall has done just that, and maintained it for years in a valiant and highly successful effort (http://macall.net/). I am assuming you have a working packet driver and the wattcp infrastructure installed; FreeDOS installed in say VirtualBox as per its defaults will usually fulfil this, though I am working on bare metal.

  1. First, find and download pmail350.zip. Perhaps here: https://archive.org/details/pmail-350.
  2. Second, go to http://macall.net/ and grab PMPULL and PMSMTP32 latest versions.
  3. I suggest unpacking all 3 archives in side-by-side
    directories, at least for now. My structure is that
    I have c:\net2\pmail c:\net2\pmpull and c:\net2\pmsmtp. Eventually, everything we need will be in the pmail folder.
  4. First, get the pull agent to work; once it is working, we can copy pmpull.exe and pmpull.cfg into the pmail folder.
    1. cd into the pmpull folder and unzip the archive
    2. have a look at the docs, then edit the pmpull.cfg file. It contains a lot of really useful comments and examples. In it, you’ll see a lot of lines beginning with # — these are comments. I am leaving them out of what I show you; they are all there in the zip.
    3. The active lines in my pmpull.cfg are:
      my_ip = dhcp
      bootpto=30
      mss=576
      maildir=c:\net2\pmail\mail\
      rettime=365
      pop3host=pop.gmx.com:995
      pop3sec=LegacySSL
    4. If using static IP, you’ll need to specify gateway, nameserver, and all that.
    5. maildir is where the new mail will be dumped (create it to match the entry in the file). pop3host is the POP3 server and its port number (get this from provider website, usually) and pop3sec is the security protocol. The port changes with protocol. If your provider uses 2-factor authentication, you’ll need an app password, and some providers do not provide these, and they won’t work with this approach.
    6. Now, you pull the email off by running:
      c:\net2\pmpull\> pmpull myemail@server.com Password
    7. Note that the password is in the clear (it may be your app password), so you don’t want to put this in a batch file with the password included! So it is best to run it manually at the start of your session. The simplest thing to do is probably to copy pmpull.exe and pmpull.cfg into your pmail folder and put that folder in the path; but you could simply cd into your pmail folder at the start of each session.
    8. Once the pull has worked, you will see files in maildir; they will have obscure coded names with CNM extensions.
  5. The CNM files are the new mail files. If you now run pmail, you’ll be able to see them. But first, we have to do some configuring of pmail.
    1. In the pmail folder, run pconfig.exe.
    2. First, choose standalone config and put your mail folder in there. At the least, your new mail folder must match the one in pmpull.cfg, because that tells pmail where to look for new mail.
    3. Second, manage user-defined gateways and create a new one. Put the correct new mail folder in here, and we’ve already seen that new mail is *.cnm, so that is the new mail search mask. Set your outgoing mail folder — this could be a new folder that you create. I’ve used c:\net2\pmail\mailout.
    4. Note that in pmsmtp.cfg and pmpull.cfg, these mail paths must have a trailing backslash!!!!
    5. Filename format must be specified as: ~d~d.MSG
      (this is a pmail language, but the key thing is that the sending agent will expect MSG extensions, which is not the default. The ~d~d is code for ‘make up some unique forename’ — remember that DOS file names only have 8 chars!)
    6. Then we set Reply address format to: “~p” <~n>
      (Again, this must be exact; it basically constructs the header that the sending agent expects. This is all in the very excellent docs.)
    7. Accept SMTP address = Y
    8. Simple message headers must be ‘Glue’
      (Again, this is part of constructing the outgoing mail so that when the sending agent looks for it, it finds what it expects.)
  6. If you save all that and run pmail, you should log into pmail with the email address you’ve set up (you can add it as a command line argument to pmail if you want to save this step routinely — see batch file snippet below), and then look for new mail, if you’ve pulled any down.
  7. You can do some configuring (Preferences — General Settings is useful for working dir, reply names, and sigs).
  8. Then you could write a new email and ‘send’ it using Ctrl+Enter
  9. Quit pmail.
  10. In your mailout folder, you should have an msg file, waiting to go; but now we need to configure pmsmtp32. Again, it has pretty useful docs.
    1. The main cfg file is pmsmtp.cfg (in the pmail folder); mine looks like this:
      my_ip=dhcp
      bootpto=30
      mss=576
      b64usrid="***redacted***"
      b64passw="***redacted***"
      maildir=c:\net2\pmail\mailout\
      smtphost=mail.gmx.com:587
      smtpsec=STARTTLS
    2. Now, the main trick is getting the b64userid and b64passw fields. For this, we can use pmail itself. (From the docs.) These are your login (email address, usually) and your password, mime encoded, and we can get pmail to do the encoding.
    3. In DOS, type:
      copy con pass
      YOURPASSWORD^Z<Enter>
    4. That is, we are going to copy from the console (screen) to a file called pass. <Enter> means hit Enter key and ^Z means Ctrl+Z
    5. So you type your password, you DO NOT hit Enter (we do not want an Enter character in the file! It will get encoded and make it wrong). Instead, you type Ctrl+Z to tell DOS to end the input, then hit Enter.
    6. Do the same for your email. Something like:
      copy con email
      myemail@server.com^Z<Enter>
    7. Now, run pmail.
    8. Create a new message and choose: “‘Send a mail message'”; attach these two files (pass and email), and choose the encoding as Basic Mime.
    9. Ctrl+Enter to exit the attach dialog, and again to send.
    10. Quit pmail.
    11. cd to your mailout folder and you’ll find 3 new files. One is the message, and two are the attachments. At the very end of each of the attachment files (which are pretty self-explanatory) you should see a line like:
      aBfhd5gdhej==
      this is the mime-encoded password or email. Copy these bits into the cfg file as above where I have put ‘***redacted***’. Note use of double-quote marks.
    12. Note that pmsmtp.cfg has the outgoing mail folder as the maildir variable.
    13. In DOS, we can put pmsmtp32.exe and pmsmtp.cfg into the pmail folder and in there type:
      pmsmtp32
      and with any luck it will find your queued messages and send them.
  11. Now, it should be possible to pull and send from within pmail. Within pconfig and the gateway config, you can put a send command, which might be basically \path\to\pmsmtp32 if you are allowing the config file to hold your password, or \path\to\mysend.bat if you are using some custom batch file to send (or a COM file if you are using the bat2exe route; see below).

Because pulling the mail needs a plain password, you probably don’t want to do that inside your pmail session, since that would require storing the password in the clear somewhere.

But you can if you want …

So a session would be:

  1. pmpull to get the mail
  2. pmail to read and create
  3. pmsmtp32 to send, run from within pmail if the base64 password is in the cfg file or outside if to have to type it out on the command line.

Now, obviously it is possible to write batch files to run the pull and send commands, but as noted they will have passwords in them — in the clear in one case, and very weakly encoded in the other (strings encoded in base64 will be pretty recognisable to people with a little knowledge of the encoding). If you can be bothered, you might be able to at least protect things from less-expert eyes. For example, there are programs to convert batch files to binary COM files (though sometimes the text within is in the clear); there are executable encoders (netrun21.zip) and compactors (UPX) that might be able to take your binary-fied batch file and remove any human-readable components.  If you like writing code, you might be able to write a C program (say) that somehow runs the push or pull program; then if the C source is not kept on the computer and the binary is run through UPX or something … etc.

Of course, these days, we rely on our login password a lot — often our passwords are stored in the browser, there for anyone who can crack our login code. So this method is I guess not as bad for security as it may seem; but because DOS does not have a login manager, if security is an issue, you might want to, if you can, set some kind of boot password in BIOS.

Of course, if someone boots your computer off a live disc/USB, they’ll be able to read any non-encrypted passwords anywhere on you DOS drive (or on a non-encrypted Linux drive for that matter), which means if the box is not physically secured a BIOS password and boot settings that do not permit boot from external media is probably as good as DOS security is going to get.

if we have an obfuscated binary to pull the mail, (call it mailpull.com), and a similar one to send it (but called from within pmail), we might create a pmail.bat and put it in our path (c:\freedos\links in FreeDOS):

@echo off
set startdir=%cd%
cd \net2\pmail
mailpull.com 
pmail -u myemail@server.com
cd %startdir%
set startdir=

So this will store the current dir, go to the pmail dir, get new mail, run pmail (which calls the sending agent internally), then exits and takes us back to the directory where we started.

This all assumes you only want to use a single email address. You can set up several gateways within pmail, but if I wanted to run more than one account, I would (cheating, I know) probably just have parallel installations of pmail, with a series of batch files — instead of pmail.bat, I would have gmx.bat gmail.bat and so on, and run them separately; but that all depends on how you use your acounts. I don’t have much crosstalk between the couple I have.

 

Back to the past

Author: Darren

I'm a scientist by training, currently working as a writer, trainer and editor.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.