HTML emails in Pegasus Mail 3.50 on FreeDOS

Pmail works well on FreeDOS if you use some great new tools to grab and send the mail.  But a lot of emails are written in HTML these days, and old Pmail does not render that (current Pmail does, I hasten to add). FLmail does, but it does so somewhat slowly. In Pmail, if an email is all HTML gobbage, and I can be bothered, I eXtract it to a file then run my little batch file:

c:\> htmemail.bat file.htm

Here is the batch file:

@ECHO OFF
COPY %1 temp$$$$.htm
REM Make sure the pattern is on a new line.
REM (And lower case.)
SED -i "s/HTML/html/g" temp$$$$.htm
SED -i "s/<html/\n<html/g" temp$$$$.HTM
REM Then delete the lines in front of the pattern
VIM  -c "g/<htm/1,-1d" -c "wq" temp$$$$.htm
REM Then view it
CALL LINKSG temp$$$$.htm
REM Then delete the copy
DEL temp$$$$.htm

It uses DOS versions of SED and Vim. SED does a nice job of preparing the file — changing HTML to html to simplify the next line, then making sure that the <html> token appears on a new line by finding it in the file and prepending a newline (\n) character; note that this requires GNU SED, and BSD SED works differently.

PMAIL (Pegasus mail)

The VIM editor is also used as a command line processor, so this needs VIM.EXE and SED.EXE to be in the PATH. VIM is part of FreeDOS.

(Some HTML emails seem to be just one long line of stuff, which is why I search for<html> and replace it with itself prefixed by \n (newline), which makes sure the pattern is on a new line.)

Then the VIM incantation finds the pattern and deletes everything in front of it. This may not always be needed — many HTML viewers can ignore the cruft before <html>, but I found that LINKS was sometimes seeing the crap at the front as indicative that the file was a plain text file, and then rendering it accordingly…

Note that LINKSG.BAT is just a batch file to call the graphical interface version of LINKS:

c:\net\links\links -g -mode 1024x768x32k %1 %2 %3

And here is the SED information, for reference:

c:/freedos/bin/sed (GNU sed) 4.2.2
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jay Fenlason, Tom Lord, Ken Pizzini,
and Paolo Bonzini.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:''
field.

AOL email on DOS (FreeDOS)

AOL email can be made to work on FreeDOS. This is really rather nice. This is how I do it. There is some configuration, but it is far from impossible.

First I logged into my AOL email account and created an ‘app password’.

  • logged in at https://mail.aol.com
  • clicked on my account name at top-right, and selected Account Info
  • clicked on Security
  • clicked on Generate and manage app passwords.

The password is a string of 16 characters. AOL will present it in 4 groups of 4, like this: aaaa bbbb cccc dddd; but you type it in all in a row: aaaabbbbccccdddd.

On the FreeDOS box, I created the folder

C:\NET2\AOL

I unzipped the PMAIL350.ZIP archive in this folder.  In the AOL folder,  I created subfolders AOLIN, AOLOUT and AOLMAIL.

Next, I needed the programs to get and send the mail. These are PMPULL and PMSMTP from http://macall.net. Amazing stuff!

I unzipped these elsewhere, and copied PMPULL.EXE, PMPULL.CFG, PMSMTP32.EXE and PMSMTP.CFG into the AOL folder.

First, we can set up PMPULL to pull the mail off the server. For that, we edit the configuration file:

C:\NET2\AOL\> type pmpull.cfg

my_ip=dhcp
bootpto=30
mss=576
maildir=c:\net2\aol\aolin\
rettime=365
pop3host=pop.aol.com:995
pop3sec=LegacySSL

The main things here are the AOL POP3 server and port, the LegacySSL flag and the folder I want the mail dumped into. Note that this assumes I have a working packet driver for DOS networking, and a valid WATTCP.CFG file, whose folder is pointed at  by the environment variable of the same name:

set WATTCP.CFG=C:\FREEDOS\BIN

To pull off the mail, I need to type something like:

C:\NET2\AOL\> pmpull email@email.email password-in-the-clear

I can put this line in a batch file called (say) PULL.BAT, but if I do so I am storing my password in the clear. So if that is a problem I can:

  • stop
  • password the BIOS on the computer
  • live with it
  • retype the app password whenever I want to get mail
  • go through some contortions to turn the batch file into an obfuscated binary.

Whatever. This worked, much to my surprise. Now, I had to set up PMAIL.

PCONFIG

I ran PCONFIG.EXE and …

  1. First, chose Standalone config and told it my mail folder (C:\NET2\AOL\AOLMAIL).
  2. Second, selected Manage user-defined gateways and created a new one called AOL. Put the correct new mail folder in here (C:\NET2\AOL\AOLIN), and put *.cnm as the new mail search mask. Set  outgoing mail folder — I’ve used C:\NET2\AOL\AOLOUT (error in the image…).
  3. Note that in pmsmtp.cfg and pmpull.cfg, these mail paths must have a trailing backslash!!!!
  4. Filename format must be specified as: ~d~d.MSG
    (this is 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!)
  5. Then 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 for PMSMTP.)
  6. Accept SMTP address = Y
  7. 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.)
  8. In the box for the program to run when sending mail, I put PMSMTP32.

Now, created PMSMTP.CFG — but first I need to MIME encode my username and password.

  1. For this, I can use PMAIL itself. (From the PMSMTP docs.)
  2. In DOS, typed:
    copy con pass
    MYPASSWORD^Z<Enter>
  3. That is, copied from the console (screen) to a file called pass. <Enter> means ‘hit Enter key’ and ^Z means Ctrl+Z.
  4. Typed my password, but did not hit Enter (don’t want an Enter character in the file! It will get encoded and make it wrong). Instead, typed Ctrl+Z to tell DOS to end the input, then hit Enter.
  5. Did the same for my email. Something like:
    copy con email
    email@email.email^Z<Enter>
  6. Now, ran PMAIL.

    PMAIL (Pegasus mail)
  7. Created a new message and attached these two files (pass and email), and chose the encoding as Basic Mime.

    PMAIL message editor
  8. Ctrl+Enter to exit the Attach files dialog, and again to send.
  9. Quit PMAIL. PMSMTP32 complained because it could not send them … of course.
  10. In AOLOUT, found  3 new files. One was the message, and two were the attachments. At the very end of each of the attachment files (which are pretty self-explanatory), found a line like:
    aBfhd5gdhej==
    this is the mime-encoded password or email. Copied these bits into PMSMTP.CFG as shown below.  Note use of double-quote marks.
C:\NET2\AOL\> type pmsmtp.cfg

my_ip=dhcp
bootpto=30
mss=576
b64usrid="AAAAAAAAAAAAAAAAAAAAAAAAAA=="
b64passw="AAAAAAAAAAAAAAAAAAAAAAAAAA=="
maildir=c:\net2\aol\aolout\
smtphost=smtp.aol.com:587
smtpsec=STARTTLS

Note the AOL SMTP address and port, and the maildir. b64userid is the MIME-encoded email address, and b64passw is the endcoded password.

So what happens here is that PMSMTP32 when run will look for mail ready to send in the AOLOUT folder and, if found, will send it.

Next. I wrapped it all in a batch file called AOL.BAT, which I put in my PATH.

@ECHO off
REM Disable CLOCK, because PMAIL has its own...
CLOCK /D /Q
REM Time zone stuff does not seem needed for AOL -- but may
REM be needed by servers I send mail to from AOL, so keeping...
ECHO Set the time zone to EST before starting Pegasus mail.
ECHO This is so that the time in the header of any mail
ECHO to be sent does not confuse any mail servers.
ECHO My time and date:
DATE /D
TIME /T
set TZ=EST
C:\NET\PICOSNTP\PICOSNTP /q /d5 pool.ntp.org
C:\NET\PICOSNTP\PICOSNTP /q /d5 pool.ntp.org
ECHO EST time and date:
DATE /D
TIME /T
SET STARTDIR=%CD%
C:
CD \NET2\AOL
CALL PULL.BAT
PMAIL -U email@email.email
CD %STARTDIR%
SET STARTDIR=
ECHO Time should now go back to Australian
ECHO Eastern,if I have the TZ code correct...
SET TZ=AEST-11AEDT
C:\NET\PICOSNTP\PICOSNTP /q /d5 pool.ntp.org
C:\NET\PICOSNTP\PICOSNTP /q /d5 pool.ntp.org
ECHO My time and date:
DATE /D
TIME /T
CLOCK /E /Q

It is pretty self-explanatory, but that has never stopped me before.

First, I want to be able to run it from anywhere, so I put this file in my C:\BIN folder, which is in my PATH. However, these programs work best when run from the directory where they live, so I save the current path to STARTDIR then go to the AOL PMAIL folder and start the real work.

I set the computer to US EST time by changing the TZ variable and running picoSNTP (comes with FreeDOS). I run it a couple of times to be sure (learned this by trial and error). Australia is in a time zone ahead of the US, and if PMAIL constructs a mail header with a date and time in the future, and PMSMTP32 tries to send that mail, some mail servers will check the time, not realise the time zone (if indeed that information is in there), and reject the mail as being impossible.

The batch file runs PULL.BAT — that is, I check for new mail at the start of my session. I can set it up to check from within PMAIL, but I did not; I do not check again during the session. This is not as big a deal as it sounds, because DOS is single-tasking, so I cannot leave the email program running — I exit out of it to do other work, and when I rerun AOL.BAT the check for new mail happens again. The check takes a minute or so, but I do not find it onerous. I like the idea of downloading the email, deadling with it, and exiting. Exiting is great. I feel like modern email is always there, just waiting to give me something to do…

Then I run PMAIL and do whatever I need to do. Read and send email, presumably, including sending files. You can shell out from within PMAIL, and view any emails you’ve saved as HTML (I have not tried this extensively). If you use this a lot, you’ll find that many of the sites that send you automatic emails and bulletins will have an option for plain text emails, which will be a lot easier to read.

When I write a new email inside PMAIL, it is saved in the AOLOUT folder. When I send the email, PMAIL invokes PMSMTP32, which looks for any messages in that folder and sends them one after another until they are all gone. It will flash up some messages one the screen while doing so, which may look a bit messy. If you catch a hint of anything looking wrong, shell out (Ctrl-F10) and look in the AOLOUT folder. If it is not empty, something went wrong.

When I exit PMAIL, the batch file takes me back to the folder where I was and resets my clock.

Security — well, what do you expect? Yes, as things are, PULL.BAT stores an email address in the clear. PMSMTP.CFG stores one only weakly encoded, and and I’ve told you how. So security is ‘none’. Assuming your computer is physically safe, or BIOS passworded, the main risk actually comes from dual booting. No one is going to log into your DOS computer from the outside. It’s not running any background services that can be exploited. I guess if you run some malware it could search the hard drive and upload stuff to somebody. If the computer dual boots with Windows or something, then if your Windows installation is compromised, somebody might be able to run something in the background while you are happily using Windows, and could find the DOS drive and then see the passwords.

I would recommend that any accounts that you set up for DOS emailing are secondary ones. Don’t use the one you use for password recoveries, internet banking and all that. Set one up just for using from DOS.

 

gmx

Note to self; odd email error pmsmtp and GMX mail

Very much a note to self. (This is so specific to my messing around on FreeDOS… really just recording it here in case I need to do it again.)

Recently set up Pegasus mail on FreeDOS using pmsmtp as the sending agent. Worked great with GMX mail (which as yet does not demand 2FA). Then set up a few other things, including the correct time zone (TZ variable), and the mail sender stopped working. Specifically, I found that when I set my timezone using the sort of notation that FreeDOS has introduced (eg set TZ=AEST-11AEDT), then this gets used by Pegasus mail to construct the email, and then the mail provider (GMX) does not understand it and sends back an error message. Here is the pmsmtp32 output:

Received: 554-Transaction failed
554-Reject due to policy restrictions.
554 For explanation visit https://postmaster.gmx.net/de/case?c=hi&i=ip&v=1.145.66.107

SMTP host's expected response is missing, here. Sorry.
Mail file(s) still waiting to be sent.

And the page it points to is about nonconformance with RFC 5321 and RFC 5322.

If I change TZ to (say) EST, and make sure the time is not in the future, then the mail sends. So I have had to use a kind of batch file as a wrapper, and then use picosntp to set the time given the time zone:

[mailpull.com is just my binary-fied batch file to pull down the mail. It’s a crude way of obfuscating the password in the clear; not that it matters — the computer is pretty physically inaccessible!]

@echo off
set TZ=EST
c:\net\picosntp\picosntp /q /d5 pool.ntp.org
set startdir=%cd%
c:
cd \net2\pmail
mailpull.com
pmail -u username@gmx.com
cd %startdir%
set startdir=
set TZ=AEST-11AEDT
c:\net\picosntp\picosntp /q /d5 pool.ntp.org
date /d
time /t

So what this does is change the time zone to EST, because nothing is going to complain about a US time zone, but then resets the computer time using picosntp to make sure the time on the email is not in the future (which is also a problem), then we pull down the mail, log into Pegasus mail, write the new mails, which pmsmtp32 sends; then on exit the TZ is reset and the time is reset and then checked.

I should really save the former time zone to a variable and restore it from there, but it’s not like I am going to move the computer to a new time zone.

Works!

Roundcube email in a third-part client

These are just my notes on setting up Roundcube email in desktop mail (eg Pegasus mail).

If your address is something like

fred@myserver.org

then to set up a mail client rather than use the web portal, your IMAP server is probably:

mail.myserver.org

your port is 993 and your security protocol is SSL.

Put your user name and password in as appropriate (depending on your email program):

The configuration box in pmail. IMAP server is mail.myserver.org and port is 993If need be, choose SSL separately:

Box for Direct SSL connect has been checkedFor sending, it’s much the same; in my case the SMTP server is the same address as the IMAP server:

mail.myserver.org

and I can choose STARTTLS or SSL. For STARTTLS, port is 587, for SSL it is 465.

I found both worked. Again, putting my login information in as appropriate.

SMTP config -- STARTTLS is checked (port 587), and user name and password entered as neededEasy.

 

Peasy

Email on FreeDOS in 2023 — Pegasus Mail

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