Helping you work smarter

Using Blat, Stunnel and Gmail Together

I’ve been a long time fan of blat, a command line utility that uses SMTP for sending quick messages.  The problem is that a SMTP Server isn’t always available to every computer.  For awhile, I was loading a separate SMTP Server program on any computer that I needed to use blat on.  I have since found a far easier method.  Enter Gmail.  The geniuses at Google have done it again, allowing the smtp protocol to be used by your Gmail account.

The first step is to download blat and extract the 3 files to your C:\WINDOWS folder.  Next.. download Stunnel to your computer.  I was attempting to setup Gmail’s SMTP for quite a while before realizing that SSL is required and that’s why I couldn’t connect.  This is a good thing though.. as we are now assured the messages we send to Gmail from blat are completely secure.  Stunnel provides the tunnel.  After downloading and installing, you’ll need to edit your stunnel.conf file with the following settings (yes, just overwrite everything in the file with this):

# GLOBAL OPTIONS

client = yes
output = stunnel-log.txt
debug = 0
taskbar = no

# SERVICE-LEVEL OPTIONS

[SMTP Gmail]
accept = 127.0.0.1:1099
connect = smtp.gmail.com:465

[POP3 Gmail]
accept = 127.0.0.1:1109
connect = pop.gmail.com:995

Now, start the service and then ‘Run Stunnel’ (both options from Program Files). stunnel – install to Install NT Service

Your secure tunnel is established.  (We’re not actually using POP3 settings since we’re just interested in creating outgoing (SMTP) mail, but if you setup an email client (Oulook, Thunderbird, etc..), you could enable POP3 in your gmail settings and take advantage of this also. ) 

Finally, run the blat command line options to install SMTP to your computer and run the batch file we create for our command line reminders.  Pull up a command prompt and this to install:  blat -install smtp.gmail.com youremail@gmail.com -u gmailusername -pw gmailpassword – – gmailsmtp

This creates a registry entry with your smtp profile including a gmail encrypted username and password. Next up.. create the batch file that we’ll call when we type in the command line. It’s just as simple as this: c:\windows\blat.exe -p gmailsmtp -to youremail@gmail.com -subject Note: -body %1 -server 127.0.0.1:1099

Access – see Santa Costume Room

Leave a Reply

Your email address will not be published. Required fields are marked *