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

Word opens wrong email client

I have Outlook for work and Pegasus Mail for not work. I like Pegasus mail, but when logged into my work account I want Word to call Outlook when I choose to ‘Share’ a document. Outlook is set as the default mail App in Windows defaults. Word calls Pegasus nonetheless.

pegasus mail and outlook logos

(Is it just me or does the Pegasus Mail logo look rather like it might be a Steve Miller Band album cover?)

Files of extension .eml, .vcs, .oft, .ics, .hol are associated with Outlook. Nothing  in the extensions list is associated with pmail, Pegasus, WSENDTO or even anything that looks like an intermediary. In Settings, I can find ‘default applications by protocol’, and Outlook is already associated with MAILTO and FEEDS, but not OUTLOOKMAIL, which points at Windows Mail. Nothing points to anything like pmail, Pegasus, WSENDTO or even anything that looks like an intermediary. If I go to ‘Set defaults by app’ … I see Outlook is already associated with everything relevant; Pegasus is associated with literally nothing. And … Word still opens Pegasus. I can only assume there’s a setting in the registry that the Settings interface is not finding. It could be that Pegasus, which has been around a long time, is writing something to the registry that the more modern configuration tools no longer look for, but which Word still hooks into.

OK, let’s look in the registry. A quick search finds a few relevant keys occupied by Pegasus Mail or one of its helper programs:

  • Computer\HKEY_CLASSES_ROOT\WSendToURL\shell\open\command
  • Computer\HKEY_CURRENT_USER\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache

But these don’t matter; they are just Windows telling itself that Pegasus Mail exists, so they won’t be the problem.. What about:

  1. Computer\HKEY_CURRENT_USER\SOFTWARE\Classes\mailto\DefaultIcon (current value: C:\MAIL\Programs\WSENDTO.EXE,0)
  2. Computer\HKEY_CURRENT_USER\SOFTWARE\Classes\mailto (current value: “C:\PMAIL\Programs\WSENDTO.EXE” %1)
  3. Computer\HKEY_CURRENT_USER\SOFTWARE\Clients\Mail (current value: Pegasus Mail)

Let’s look at these 3 keys. Naively, I can make them all point to what I hope are the analogous binaries/entries for Outlook, so I changed the key contents to:

  1. “C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE”,0
  2. “C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE” %1
  3. Outlook

And now it works. I can say it did not work after changing just the first 2, and I do not know if it was only the third one, or all 3 that made the difference, but now Share from Word opens Outlook.Whether I’ve introduced some other error, I guess I’ll find out over time.

These are all keys for the ‘current user’, so I hope they won’t have a global effect! I’m never sure with Windows…

Look out, Pegasus!