Friday, March 18, 2011

Use BLAT With STUNNEL To Send Email Via SSL On Windows

An earlier post described a Windows command-line script which sends a detailed email at bootup, like PC Phone Home (tm). It worked on our computers for a year and a half, and then stopped. We discovered that our internet service provider, trying to reduce the amount of spam sent through their servers, had blocked port 25, the standard unencrypted email port. They encouraged their customers to switch to SSL, encrypted transmission, using a different port.

The BootMail script uses a free utility called blat to actually send its email. Unfortunately, blat does not support SSL connections. However another free utility, stunnel (secure tunnel?), can convert data from an SSL-ignorant program like blat and send it to an SSL-aware computer or connection. Stunnel can do lots of other things too, and in fact I found the documentation to be thoroughly daunting, but installation turned out to be quite simple, basically the same on Windows 7, Vista, and XP:
  • Download stunnel-4.35-installer.exe from stunnel.org.
  • Run it and accept the defaults. This installs the software on the disk, in c:\Program Files\stunnel on a 32-bit system or c:\Program Files (x86)\stunnel on a 64-bit system.
  • In Start/Programs go to the new stunnel folder and right-click on "Edit Stunnel.conf." Click Run as Administrator (Vista or W7), or click Open (XP). This brings the configuration file into Notepad with rights to modify it. You may be prompted for permission in this and following steps.
  • Delete everything in the file, and copy in the four lines example below, modifying them for your use. "Accept" is the port on which blat sends the email (this can be changed), and "connect" is the server name and port that your ISP wants you to use. Save and quit.
  • In Start/Programs, right-click "Service Install" and click Run as Adminstrator.
  • In Start/Programs, right-click "Service Start" and click Run as Administrator.
Example stunnel.conf file which could be used to send email through gmail:
client = yes
[ssmtp]
accept  = 25
connect = smtp.gmail.com:465
In the script which runs blat, or in the registry, you will want to specity the server as follows: "-server localhost:25".

(tm) PC PhoneHome is a trademark of Brigadoon Software.

7 comments:

Chimpunzee said...

Thanks! This is exactly what I was looking for.

Yabits1 said...

Thank you very much for sharing this! It worked perfectly for me.

Gary and Kay Fortune said...

When I try to start stunnel I get the following error. Any ideas?
Error binding service [ssmtp] to 127.0.0.1:25
bind: Permission denied (WSAEACCES) (10013)
Closing service [ssmtp]
Service [ssmtp] closed (FD=1776)
Sessions cached before flush: 0
Sessions cached after flush: 0
Service [ssmtp] closed

Server is down

Gary and Kay Fortune said...

I get the following error when trying to start stunnel. Any ideas?

Error binding service [ssmtp] to 127.0.0.1:25
bind: Permission denied (WSAEACCES) (10013)
Closing service [ssmtp]
Service [ssmtp] closed (FD=1776)
Sessions cached before flush: 0
Sessions cached after flush: 0
Service [ssmtp] closed

Server is down

Don said...

Hmmm - sounds like you don't have a high enough permission level, are you starting it as an administrator? What operating system?

Ming Kuan Ang said...

well done, Sir. It is simple and easy to follow.

Ming Kuan Ang said...

Well done sir. It is simple and easy to follow.