1

I need to send an email from a batch script. I tried several solutions without success.

For example, with Blat:

:send_mail
"\Program Files (x86)\blat275\full\blat.exe" 
    -server smtp.gmail.com
    -port 525
    -f myAdress@gmail.com
    -to recipient@foomail.com 
    -s "hello"
    -body "world"

When I run the script, I just get a Windows crash:

A Win32 command line eMail tool stopped working

Does someone have a better solution?

EDIT & SOLUTION

I tried on our server (with our smtp) and it worked with Blat. See the full code in my answer below.

Community
  • 1
  • 1
GG.
  • 21,083
  • 14
  • 84
  • 130
  • In reality are you passing the arguments in a single line? – Alex K. Oct 13 '11 at 13:37
  • Yes I indented to avoid the scroll – GG. Oct 13 '11 at 13:39
  • 1
    FWIW, I've been using [XmlSendMail](http://www.daveswebsite.com/software/sendmail/) for a few years, and never had any problems with it. Won't help you solve your current issue, but if you give up on blat (which is an interesting word in Russian...), give it a try. – Eran Oct 13 '11 at 13:55

4 Answers4

6

Realize this is old, but for any googlers:

Blat will NOT work with gmail, as it requires an SSL connection to be accessed over SMTP, which blat doesn't (as of 06/02/2013) support

See here: http://www.jeffkastner.com/2010/01/blat-stunnel-and-gmail/ for a (slightly messy) workaround.

Kaelan Fouwels
  • 1,155
  • 1
  • 13
  • 28
4

With Blat on my server:

SET to=myEmail@gmail.com,myOtherEmail@gmail.com

SET server=127.0.0.1
SET port=25
SET from=bot@foo.com
SET subject="BACKUP PROBLEM"

SET year=%DATE:~6,4%
SET month=%DATE:~3,2%
SET day=%DATE:~0,2%
SET today=%year%-%month%-%day%

"\Program Files (x86)\blat275\full\blat.exe" -server %server% -port %port% -f %from% -to %to% -html -s %subject% -body "%today%: bla bla bla"
GG.
  • 21,083
  • 14
  • 84
  • 130
3

You can use mailsend instead. As @kfouwels mentioned, blat does not support SSL.

Community
  • 1
  • 1
romar
  • 804
  • 7
  • 17
2

Blat do not support SSL/TLS mail servers. This is why you can't send an email.

Use Mail Alert Simple Mailer instead of Blat: https://sourceforge.net/projects/mail-alert/

Admin
  • 29
  • 1