Sei sulla pagina 1di 12

Using Blat, Stunnel and Gmail Together

by Jeff Kastner | posted: January 13, 201039 comments

I was looking for a way to create quick reminders for myself. After trying a few different programs, I looked to the command line to see what I could come up with. It turns out that command-line email is perfect for my needs. By combining Blat, Stunnel and Gmail, you can create a great reminder system for taking quick notes. Ive 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 isnt 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 Gmails SMTP for quite a while before realizing that SSL is required and thats why I couldnt 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, youll 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). Your secure tunnel is established. (Were not actually using POP3 settings since were 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 well call when we type in the command line. Its 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 Name your file note.bat and drop it in C:\WINDOWS as well. Now, pull up a command prompt and type: note heres some text to send Check your email.. and theres your new note. Keep in mind that you can send your email to anyone, as youre just using the SMTP protocol from a designated gmail account. You also have a huge amount of other options that you could include your batch file so check out the blat syntax. Youre only limited by what blat cant do and blat can do a lot!

Jeff Kastner
Jeff Kastner has extensive experience in Remote Network Administration, Software Application Deployment, PHP Development, Graphic Design, CSS integration, usability and accessibility as well as SEO.. View all posts by Jeff Kastner

Recent Posts

Order a Classifieds Site For Sale PREPOPULATED! My Google Keyword Scraper Tool Goodbye Google Suggest API. You Will Be Missed! Leaked Google Document Shows How Websites Are Rated Trending Topics My Latest Website

39 Responses to Using Blat, Stunnel and Gmail Together

1.

Marcy
January 25, 2010 at 10:37 pm#

Hi. Im trying to make this work but Im confused on how to get Stunnel going. I downloaded it and installed. Is it just running now?

2.

Jeff
January 27, 2010 at 12:19 pm#

Marcy.. Youre making it too hard. Look in Program Files after you install Stunnel. Its all right there.. Install the Service, Run it and then just click on Run Stunnel. You used to have to manually configure everything with Stunnel. Now its pretty seamless. Theyve done a great job improving it.

3.

Brian
February 10, 2010 at 7:07 pm#

Jeff, Thank you very much for your excellent article. I followed it carefully and it worked first time.

One odd thing I noticed is that in the blat -install example the gmailpassword part has what look like two hypens but they are two different characters. They do work blat likes them. Regards, Brian

4.

Jeff
February 21, 2010 at 1:01 am#

Thanks, Brian. Im using the - - characters as defaults. If you check out the blat install syntax (http://www.blat.net/examples/install&profile.html), and look at the last example on that page, youll see those characters mean were using the default number of tries to send and port number. Granted.. I later specified a port. You wouldnt have to do that. I just realized I had to on the server I was on and thats why its in my example. Glad it worked for you!

5.

Brian
February 21, 2010 at 1:43 pm#

Jeff, Sorry guess I wasnt as clear as I could have been. I was just pointing out the odd occurrence that in your actual example what appear to be two identical hyphen characters are actually two different characters. The first is hex 96, the second hex 2D. 2D is a hyphen. Depending on program you can actually see a difference between them. In Word for example. And if you copy&paste run your example you will see that part of the output is retry time(s) instead of retry 1 time(s) Regards, Brian

6.

Ant
February 23, 2010 at 3:14 am#

Awesome Jeff, thanks this has helped me a great deal today! Just a note, is there a typo in your article where you install the blat server? I dont see the -p for the

profile name for blat, only two hyphens at the end of that command/instruction : -pw gmailpassword gmailsmtp just wondering. Thanks Anthony

7.

joe
April 10, 2010 at 9:00 am#

10/10 worked without a hitch your explanations reflects serious simplifying intelligence. i use mine to send to my phones email number (xxxxxxxxxx@vtext.com using command line.. e.g. from mIRC (a chat program).. this way other people can text me without knowing my phone number, or maybe ill set up utorrent or the like to tell me important computer events. gotta stay excessively attuned to my computer, yknow! =| thanks, tho =D

8.

joe
April 10, 2010 at 9:02 am#

+)

9.

RAG
May 14, 2010 at 5:47 am#

Jeff, I was looking for some help to send email using gmail and blat and found excellent help from this site. Tons of thanks for putting this together.

10.

Y.
December 24, 2010 at 12:24 am#

Just wanted to thank you for an excellent tutorial. Very helpful and informative for first time users. Thank you.

11.

Samy
December 27, 2010 at 8:05 am#

Hi I tried an example and this is the result : Error: Connection to server was dropped. SMTP server error Error: Not a socket. Error: Not a socket. Can you help me please ?

12.

gt57
January 4, 2011 at 8:48 pm#

The install parameters dont match to the Blat 2.6.2 help:

13.

Jeff Kastner
January 17, 2011 at 6:27 pm#

@gt57 You must not be familiar with the command line. You can specify your variables at any place doing it as I have or using the manual and doing it exactly as it states, as you or others may need to do. Notice those replies above yours? It works for them as it has for me.. dozens of times. I copied and pasted what I use so it does work. You just need to use a bit of intelligence in implementing it.

14.

Zadock
February 18, 2011 at 6:28 am#

Thanks man, this has really gone a long way.

15.

Chris
February 24, 2011 at 10:01 pm#

I tried all kinds of other instructions. but your were simple and worked the first time. Thank you!!!!

16.

Sean
March 24, 2011 at 12:11 pm#

Nice clear instructions, worked the first time, Thanks!

17.

GM
March 30, 2011 at 1:53 am#

Absolutely Great! Thank you!

18.

Daniel Williams
April 22, 2011 at 4:00 pm#

Thank you very much quite helpful!

19.

John L
May 1, 2011 at 12:21 am#

Thanks! Was trying to get blat, stunnel & gmail working to no avail, your clear instructions and I had it working in less than 10 minutes, great info.

20.

Jeff Kastner
May 1, 2011 at 2:47 am#

Thanks, guys. Glad the information is helping others and its working for you!

21.

alexander kovalenko

May 2, 2011 at 3:50 am#

supernicelyworks! thanks a lot! But I still do not get why we need stullel. Why cant we use only Blat and Gmail?

22.

Jeff Kastner
May 2, 2011 at 11:02 am#

I explain that in the 3rd paragraph above: I was attempting to setup Gmails SMTP for quite a while before realizing that SSL is required and thats why I couldnt connect. Even if it wasnt required, I would use it. Tts an SSL encryption wrapper so you can rest assured that your messages (along with your authentication information) will never be intercepted.

23.

Marvin
May 17, 2011 at 8:29 pm#

Thanks a lot!! Very very helpful! Though i got all this done, i still have a little trouble. Its when I send email, I found out that the send time isnt correct, its less 1 hour than the actual sending time! ex: I use blat to send email at 12:00, i get the mail at around 12:00, but the send time is around 11:00. I checked my system time and time zone, they were all correct, but i still got the issue. I could not find the time setting option in both blat and stunnel. Could you help me for this or tell me where might be wrong?

24.

Jeff Kastner
May 17, 2011 at 9:33 pm#

Not sure Marvin, as Ive never had this issue. I see some others on the TechBoard have had the same problem though. You might rehash the issue and ask them. Check this link: http://tech.groups.yahoo.com/group/blat/message/11346 Best of luck.

25.

Marvin
May 17, 2011 at 9:47 pm#

Thank you!

26.

Scott H
May 21, 2011 at 4:14 am#

You could use sendEmail (http://caspian.dotconf.net/menu/Software/SendEmail/) instead of blat has TLS built in, so no need for stunnel. sendEmail + Gmail = done.

27.

Jeff Kastner
May 23, 2011 at 1:43 pm#

Nice mention, Scott. Im not familiar with sendEmail but it looks like a nice alternative solution.

28.

Paul
September 16, 2011 at 4:39 pm#

Just wanted to say thanks for this article, within 5 mins I had it running. Came across blat today as needed to email backup logs from my Veritas server, then thought abou tusing it at home also. Stunnel is cool.

29.

Jeff Kastner
September 21, 2011 at 8:56 am#

Thanks Paul. I appreciate the words. Glad it helped you out!

30.

Alex
October 17, 2011 at 5:27 pm#

The message Error: Not a socket was caused due to another service, in my case c:\windows\system32\Lserver.exe (Terminal server Licensing) using the same port 1099. Not tested yet, but changing the port to another unused in the config file should solve the problem. You can use the program active ports available in Internet to see what programis using that port.

31.

Pieter Verberne
November 27, 2011 at 5:05 am#

I have a pc with windows 7 64 bit and I am very eager to use Blat also with Google. I have followed the instructions to install Stunnel literally: Now, start the service and then Run Stunnel (both options from Program Files). Apparently before starting the service I must install it. Correct? After installing the service, starting it is no problem and it can be found in services.msc The next step, Run Stunnel, is where it goes wrong and I have no clue what to do. This is the message I get: Stunnel 4.48 on Win32 (invalid stunnel.conf) [This is the message header] No limit detected for the number of clients make_sockets: s_socket#1: FD=464 allocated (blocking mode) make_sockets: s_socket#2: FD=468 allocated (blocking mode) make_sockets: s_accept: FD=472 allocated (non-blocking mode) stunnel 4.48 on x86-pc-mingw32-gnu platform Compiled/running with OpenSSL 0.9.8r-fips 8 Feb 2011 Threading:WIN32 SSL:ENGINE,FIPS Auth:none Sockets:SELECT,IPv6 Reading configuration from file stunnel.conf FIPS_mode_set: 2D06906E: error:2D06906E:FIPS routines:FIPS_CHECK_INCORE_FINGERPRINT:fingerprint does not match Server is down End of message Any help would be highly appreciated. Many thanks indeed If I can get this to work it is probably my best X-mas present. Thanks a lot Jeff

32.

Jeff Kastner
November 27, 2011 at 12:21 pm#

Hi Pieter. I havent installed on W7 or 64-bit but the problem seems to definitely be that Stunnel is using 32-bit mode (as stated in your message header) and youre installing on a 64-bit system. I dont see separate binaries for these downloads, so I suspect that that theres some editing needed in stunnel.conf. Unfortunately, its been almost 2 years since I wrote this post or messed with Stunnel and Ive only done it with XP so Im not much help on the newer issues. It served my purpose well back when I wrote this post but I no longer need or use Stunnel. Best of luck to you.

33.

Galen Wollenberg
December 1, 2011 at 1:00 am#

i spent quite literally 2 weeks trying to get stunnel to work so my canon copier would talk to gmail. the problem was that i could enable SSL on the canon copier but i could not change the port. so it wouldnt talk to gmail. here is my stunnel.conf for any one who is having as much trouble as i did getting stunnel and gmail to work. the gmail account has pop/imap enabled in the mail settings in gmail. 192.168.150.2 is my internal windows server running stunnel. i could not get 127.0.0.1 to work. i just put my stunnel servers ip in the copier as the mail server 192.168.150.2. also i think i had to turn off smtp auth on the copier for it to work. your mileage may vary just copy paste this into your stunnel.conf for gmail. cert = stunnel.pem socket = l:TCP_NODELAY=1 socket = r:TCP_NODELAY=1 client = yes [pop3s] accept = 110 connect = pop.gmail.com:995 [imaps] accept = 143 connect = imap.gmail.com:993 [ssmtp] accept = 25 connect = smtp.gmail.com:465

34.

Ilir
December 25, 2011 at 1:16 pm#

I still cant get this to work, please can you send me a link to that stunnel file because there are many and i dont know which file to download thanks

35.

Ilir
December 25, 2011 at 4:34 pm#

@ECHO OFF title Menuchoice :home

color 17 ECHO Select a task: ECHO ============== ECHO. ECHO 1) Install BLAT ECHO 2) Install SMPT ECHO q) Quit ECHO. set /p web=Type option: if %web%==1 goto FIRST if %web%==2 goto SECOND if %web%==q Exit cls goto home :FIRST blat -install smtp.gmail.com JOHN.DOE@gmail.com -u JOHN.DOE -pw JOHNY1991 gmailsmtp pause cls goto home :SECOND c:\windows\blat.exe -p gmailsmtp -to JOHN.DOE@gmail.com -subject DEAR SANTA -body HOW ARE YOU -server 127.0.0.1:1099 pause cls goto home #whats the problem here, at the last i get errors; couldnt connect or when i change the #servers ip it seems to attempt for connecting but after 10 sec, max it says the servers #rejected the connection or something like that. #i installed [stunnel-4.50-installer.exe](926KB) to the Program Files under C: and edited #stunnel.conf, moved the three (BLAT) files to the WIN directory and this batch i always #ran from there[which i think isnt the problem of the paths]

36.

Santi
March 6, 2012 at 11:04 am#

Thanks, Jeff I have been using an SMTP relay for years to send email via Google and this is so much simpler. It worked perfectly the first time. And all open source!

37.

Jeff
March 6, 2012 at 7:26 pm#

Santi.. Glad it worked well for you! Thanks for letting me know! Have a great one,

Jeff

38.

Prashant Rathod
April 10, 2012 at 4:20 am#

Hey jeff Good trick! awesome..! i can send emails in cross domain also.! thnks!

http://rewritingnotes.wordpress.com/2011/10/07/adding-e-mail-notification-to-utorrent-when-adownload-finishes/

Potrebbero piacerti anche