Dude - Email notifications through Gmail on Windows - via blat

Related solutions
Send mail via server which require SMTP authentication
Dude - Email notifications through Gmail on Windows - via mailsend
Dude v6 - SMS notifications

Requirements

  1. Stunnel
  2. Blat
  3. Dude server on windows machine
  4. Gmail account

Setup instruction
1. Download and install stunnel

2. Create the following stunnel.conf (please backup original file and create this file from scratch)

socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
;debug = 7
;output = stunnel.log

client = yes

[pop3s]
accept  = 995
connect = pop.gmail.com:995

[ssmtp]
accept  = 465
connect = smtp.gmail.com:465

And reload config in stunnel

3. Install stunnel as service:

"C:\Program Files\stunnel\stunnel.exe" -install

or

Start --> All Programms --> stunnel --> stunnel Service Install

4. Download blat and unpack 2 files, blat.dll, blat.exe in C:\Program Files\Dude\blat directory or other directory.

5. In directory from p.2 create emailblat.cmd file with the following content

:: Send email notifications from Dude via Gmail
:: 
set blatdir=C:\Program Files\Dude\blat
set smtpsender=username@gmail.com
set smtpserver=127.0.0.1
set smtpport=465
set smtpuser=username
set smtppwd=*********
set mailto=username@gmail.com
::
::
"%blatdir%\blat.exe" -to %mailto% -f %smtpsender% -server %smtpserver% -port %smtpport% -u %smtpuser% -pw %smtppwd% -subject %1 -body %2
::
:: Uncomment for debug only (Comment previous line. Do not forget to return back after debugging!!!)
::
::"%blatdir%\blat.exe" -to %mailto% -f %smtpsender% -server %smtpserver% -port %smtpport% -u %smtpuser% -pw %smtppwd% -subject "Test subject" -body "Test body" -debug -log emailbtal.log
::
:: pause
::

change in it: smtpsender, smtpuser, smtppwd, mailto

For debugging, uncomnent appropriate line, and comment previous - then start emailblat.cmd without parameters. And do not forget to return back after debugging!!!

6. Create new Notification
Name: Email-blat
Type: execute on server

"C:\Program Files\Dude\blat\emailblat.cmd" "Service [Probe.Name] on [Device.Name] is now [Service.Status]" "Service [Probe.Name] on [Device.Name] is now [Service.Status] ([Service.ProblemDescription])"

And test it via pressing Test button

7. Now you can use it:
Dude-Email-notification-throughout-Gmail-on-Windows-machine-01.png

LOL. Put it in the wiki!

thanks! good job!!

I tried this approach with no such luck. Are all the strings to be altered listed in the emailblat.cmd? Should smtp server be the loop back address if the dude is not running smtp service?

in my way i use stunnel that work as redirector - without any SMTP server on local machine.
you must use any address of you server if it listening port that indicated in stunnel.conf.

  1. Verify if stunnel work - you must view the same results:
    telnet localhost 995
    or
    telnet 192.168.1.1 995

+OK Gpop ready for requests from XX.XX.XX.XX 37pf6537165qyk.25

telnet localhost 465
or
telnet 192.168.1.1 465

220 mx.google.com ESMTP 9sm2309658agb.29

  1. Then try to run emailblat.cmd from cmd - and see result

  2. I have a problem to send mail with blat when gmail user password contained ? or ; symbols

Where i need to put this? what file or where?


thks for your help i only need to put it to do tests

Hi.

I am new in this board, i am a new “The Dude” user.
The Dude is a nice app.
But email notification is very important for me.

I tested this workaround. Very fine using an gmail Account.

I don’t want to use an email account from gmail.
But i have a problem with my preferred account. It doesn’t use SSL.
I can only use unsecured SMTP and POP3. do you know an program, or possibility to use it in this way?

Authentication is necessary, because this feature is active to my preferred account.
When will The Dude use authentication to send mails?

I hope my english is good enough that you will understand what i want.

Waiting for answers…

thanks

I did this and it works! Very cool. In case anyone has problems reboot after installation even thought it doesn’t mention that you need to. In my case it wouldn’t work until I did.

Maybe this could be a sticky or something? It’s a very cool feature that I would have done long ago had I knew it existed.

niemandsonst
Skip step1 with stunnel install, and user blat parameters to connect to you mail server
emailblat.cmd

set dir=c:\Program Files\Dude\blat
set smtpsender=dude@domain.com
set smtpserver=192.168.0.1(you server IP)
set smtpport=25
set smtpuser=username@domain.com
set smtppwd=*********
set mailto=admin@domain.com
::
"%dir%\blat.exe" -to %mailto% -f %smtpsender% -server %smtpserver% -port %smtpport% -u %smtpuser% -pw %smtppwd% -subject %1 -body %2

I’m trying to follow the instruction above without stunnel, but it didn’t work.

i cannot receive email automatically, but if i run the .bat manually, it work, but i didn’t receive any report, just a plain text that i input on “body” and “subject”

Please tell me, what i do wrong ? I’m trying to send email to my email server at the office

c:\Program Files\Dude\blat\emailblat.cmd “Service [Probe.Name] on [Device.Name] is now [Service.Status]” “Service [Probe.Name] on [Device.Name] is now [Service.Status] ([Service.ProblemDescription])”

krissanto
In Dude, go to the Notification and open Email-blat instance - then pres test.
Verify if your path to emailblat.cmd is correct.
Now in my Windows 7 x64 path differ on that I was wrote in the first post:

"c:\Program Files (x86)\Dude\blat\emailblat.cmd"  "Service [Probe.Name] on [Device.Name] is now [Service.Status]" "Service [Probe.Name] on [Device.Name] is now [Service.Status] ([Service.ProblemDescription])"]

here is my configuration on .bat

set dir=c:\Program Files\Dude\blat
set smtpsender=test@test.com
set smtpserver=xxxxxx
set smtpport=25
set smtpuser=test@test.com
set smtppwd=xxxxxx
set mailto=test@test.com
::
"%dir%\blat.exe" -to %mailto% -f %smtpsender% -server %smtpserver% -port %smtpport% -u %smtpuser% -pw %smtppwd% -subject " tes " %1 -body " tes "%2

Like i said before, when i double click the file, it runs normally. Do i need to change setting on server configuration from setting menu, for example like General or Server ?

krissanto
This is my settings:

I am using windows 7 x64 - this worked perfectly for me - the only caveat was that i had to use the stunnel config file exactly as specified - i.e. i had to wipe out all of the other defaults that came with the stock stunnel.config.

Do you use Windows 2008 R2 perhaps? Same problem here, I think the security is tighter. I changed the account for the service even to administrator, and used cmd.exe /C to run it, without any luck..

Hi,

I’m using SBS2003 server to act is our Dude server (using STUNNEL & BLAT).
When running the emailblat.cmd file from cmd, we get the test email sent successfully.

However, we dont get the prob notification from the dude.

We use this as a notification (on the dude):
“c:\Program Files\Dude\blat\emailblat.cmd” “Service [Probe.Name] on [Device.Name] is now [Service.Status]” “Service [Probe.Name] on [Device.Name] is now [Service.Status] ([Service.ProblemDescription])”

I can see that the CMD black screen opens and closes very quickly as soon as a notification should be actioned, but no email is being send.

If I run the “c:\Program Files\Dude\blat\emailblat.cmd” “Service [Probe.Name]…” command from cmd I get this: “Do not understand argument Service [Probe.Name]…”

So the stunnel & blat are working ok, but seems that the dude wont understand the notification variables.

Any Ideas?

Hello,

I use

C:\blat\emailblat.cmd "Monitor: [Device.NetMaps] map - [Device.Name] probe [Probe.Name] is now [Service.Status]" "Hi there!||This is TheDude from the monitoring server reporting:||at: [TimeAndDate]|on map: [Device.NetMaps]|Device: [Device.Name]|Probe: [Probe.Name]|Status: [Service.Status]|Problem Description: [Service.ProblemDescription]|Changed since: [Service.TimeSinceChanged]|Last time up: [Service.TimeLastUp]"

I set it to execute on the server, and changed the service account of the Dude service to the local administrator.
FYI the || in the code above inserts a newline/enter in the email message.

My emailblat.cmd is:

rem @echo off

set dir=c:\blat
set logname=%dir%\blat-%date%.log
set smtpsender=senderadress@gmail.com
set smtpserver=127.0.0.1
set smtpport=465
set smtpuser=senderadress@gmail.com
set smtppwd=MyGmailPassword
set mailto=receiveradress@domain.com
set subject=%1
set body=%2

IF NOT EXIST %logname% echo ====================== Start of file ====================== > %logname%
echo. >> %logname%
echo ====================== %time% ====================== >> %logname%

C:
CD %dir%
echo CMD: blat.exe -to %mailto% -f %smtpsender% -server %smtpserver% -port %smtpport% -u %smtpuser% -pw %smtppwd% -subject %subject% -body %body% >> %logname%
blat.exe -to %mailto% -f %smtpsender% -server %smtpserver% -port %smtpport% -u %smtpuser% -pw %smtppwd% -subject %subject% -body %body% >> %logname%

Of course you have to change the sender and receiver address and the password. This version of emailblat.cmd also creates a log per day for all actions so you can better troubleshoot in the case of problems. Hope this helps you!

Regards, Roland

Hi Roland, thanks for your very quick reply!

I’ve made the changes to emailblat.cmd and the dude prob notification variables, nit sure about the dude service, where do you change it to use the administrator account (it’s not in services)?

In any case, it did not work, I can see the cmd black screen pops up and closes very quickly, which means its acknowledging the action, but no email is sent ..

What am I missing?

Hi again, I added the command ‘pause’ at the end of the emailblat.cmd so I can see if there are any errors while actioning that batch file - see attached.

I also noticed it’s not creating the log file like you set it up to do.

Help?
Blat.JPG

the problem is with the long path name. if you want to use it in the program files folder you have to use the short version (e.g. c:\progra~1\dude\blat) or move the blat directory. I have it in the root of C: (c:\blat). This should fix the problem..

Roland

Hi, made the change as you suggested, but still no joy.. see attached.
Maybe it’s the dude service that needs to run as administrator? where do you change that?
Blat.JPG