Blat logo What is Blat?
Blat is a Windows (32 & 64 bit) command line utility that sends eMail using SMTP or post to usenet using NNTP.

Blat SMTP mailer - Frequently Asked Questions



Blat SMTP mailer - Frequently Asked Questions

Please don't use Blat for UCE (spam)!

Why should I not send HTML or RTF formated mail?


What is Blat (and what does it do)?

Blat is a small, efficent SMTP command line mailer for Windows. It is the SMTP *sending* part of an eMail User Agent (MUA) or eMail client. As such, Blat sends eMail via SMTP (or internet eMail) from the command line, or CGI, ...


What is Blat not?

Blat is NOT a drop in replacement for the Unix SENDMAIL, MAIL, MAILX utilities (or for that matter, any other eMail tool you can think of). A Perl script written to use these, for example, will not work without some tweaking.


How big is Blat?

 Directory of D:\Tools\eMail\blat194
 01/21/2002  01:57p   36,864 blat.exe


Is there an eMail list for Blat?

Yes, check out http://groups.yahoo.com/group/blat/

Or send eMail to


Sorry for the dumb question but...

The only dumb question is the one not asked! Please go to the Blat list at Yahoo and ask!


What is the syntax for Blat?

Syntax can be found by typing Blat (with no parms) on the command line. Please try it yourself to see all the options.


What do all those syntax options mean?

Check in the Command Line items for more information.


I work in an MS Exchange environment, what do I use for the SMTP server?

Most MS Exchange systems likely have an SMTP service, you should check with your eMail administrator to find out what it is.

You do not want the \\domain\machine syntax here, but rather a DNS syntax (smtp.MyDomain.com or whatever) or TCP/IP Address. You should be able to ping to that name or address.


How do I verify the SMTP server is working correctly?

You can verify the SMTP service is working with the telnet command.

From a command prompt run:

  telnet   SMTP.Server.or.IP.Address.com   25

The server should respond with a 220 message if it is working correctly (type QUIT to end, you should get a 221 message).

 ,----- [ UC = You type, LC= SMTP Service response ]
 | C:\>TELNET SMTP.MYDOMAIN.COM 25
 | 220 mydomain.com ESMTP
 | QUIT
 | 221 mydomain.com
 |
 | Connection to host lost.
 `-----


Is there a DLL version of Blat?

Toby Korn has created a DLL version of blat. It is available from his page at http://www.geocities.com/toby_korn/blat/.


Problems... what should I check first?

Try running Blat with the addition of the -debug -log blat.log switches.


Are there any examples you can give me?

There are a bunch in the Readme.txt file that came with the Blat you downloaded from http://www.blat.net.


How, exactly, does Blat work?

Blat takes command line paramaters (and pulls some options from the Registry) to send SMTP eMail.

For more information, check the source code which is included with the distribution.


May I modify the source code to fit my needs?

Yes, the homepage says it is a Public Domain tool. Check the Public Domain licensing for exact rules & restrictions.


I have this terrific improvement to Blat. Where do I send the changes to the source?

Check http://www.blat.net


Where and how does Blat save the install configuration?

It is in the windows registry.

 HKEY_LOCAL_MACHINE \ SOFTWARE \ Public Domain \ Blat


Command Line (CL)


CL - Why should I run Blat -install...?

Because it simplifies the command line by storing any or all of the following in the regestry [HKEY_LOCAL_MACHINE \ SOFTWARE \ Public Domain \ Blat].

  SMTP Server Address
  Sender's Address
        Number of times to retry sending
        Port number to use (ie, if not the SMTP default of 25)
        The -q switch which "supresses *all* output"
 Blat -install smtphost.bar.com foo@bar.com  // Sets host and userid
 Blat -install smtphost.bar.com foo          // Sets host and userid
 Blat -install smtphost.bar.com              // Sets host only


CL - I run Kix32 for my login scripts, how can I call Blat from there?

Here is one way. If you have another, please send it on to me, I may include it.

 ,----- [ insert in your Kix32 script ]
 | IF EXIST (@LDRIVE + "LogonMessage.bat")
 |       SHELL @LDRIVE + "LogonMessage.bat"
 | ENDIF
 `-----
 ,----- [ LogonMessage.bat ]
 | @set message=Error \"logging in\" at %time% on %date%
 | @blat - -to valid@eMail.svr -server smtp.mail.svr -f Blat_Service@eMail.svr
 |         -subject "%message%" -body "%message%" -q
 `-----


CL - How do I get the `` char in a subject line (or message body)?

Use a batch file and set an environment variable for the subject, using the backslash char to escape the `` char.

 ,----- [ blat.bat ]
 | set note=Check out the \"quoted\" text!
 | blat - -to valid@eMail.svr -server smtp.mail.svr -f Blat_Service@eMail.svr
 |        -subject "%note%" -body "%note%" -debug -log blat.log
 `-----


CL - How do I send a message with no 'MAIL FROM:' address?

Use <> as the paramater for the -f switch.

        -f <>


CL - What is all this odd syntax?

SMTP eMail syntax is defined in RFC(2)822. You can look here if you really want to read it <g>.


CGI

Common Gateway Interface


CGI - How can I use Blat with CGI?

There are 2 basic ways I can think of.

1. Call Blat as your CGI application. You don't have much control over the format of the message in this method.

2. Use another CGI application (like Perl for example) to gather your CGI input and format the message. (btw, Perl can send eMail nativly...)


CGI - Can you show me example of calling Blat as my CGI Application?

Yes, one comes in the distribution of Blat, look for demoblat.htm.

Here is one tim cobbled together after playing with the one in the distro.

(Note, this looks like it may work if you try it, but as of right now, this FAQ is hosted on a unix platform, so Blat will not run.)


CGI - Can you show me an example of using Perl as my CGI Application to call Blat?

Sure, you can find them on the web.

Here is one tim cobbled together after looking at various ones on the web (but not really liking them...).


CGI - Why does Perl code written for Sendmail not work with Blat?

Blat is not a Win32 version of sendmail, and as such, you can not just change the sendmail calls in your Perl code to call Blat.exe

Sendmail is an eMail Transfer Agent (MTA).

Blat is the SMTP *sending* part of an eMail User Agent (MUA) or eMail client

Check out the ``What is Blat'' part of this FAQ.


(E)rrors

One of the first things you want to do if you are having problems is use the -debug switch (you can also use the ``-log logfile.log'' switch to put the output in a file.)


E - What does the ``Unable to relay'' error message indicate?

 <<<getline<<< 550 5.7.1 Unable to relay for valid@eMail.svr

A server will think it is 'relaying' when neither the sender or recipient address are an address that belongs to it. This is discussed more in RFC2821 (search for 'relay').

This is frequently not permitted so SPAMers are unable to use that SMTP server.


(E)xamples

I tend to run Blat where it is not an option to use the '-install' feature, so define lots of paramaters.


Ex - Using Perl to call Blat

I am not sure why one would want to use Perl to call Blat. Perl can send eMail nativly, so doesn't need Blat, and Blat has no need to be called by Perl.

However, I see the quest fairly often, so...

<Start Perl wrapper code>

 #!perl -w
 use strict;
    # declare the variables we are going to use
 my ($to, $f, $subject, $body, $server, $hostname, $u, $pw, $debug, $x, $return);
    # you must change the values marked with <-- ****
    # populate all the variables we are going to use
 $to = "-to eMail\@MyDomain.com"; #          <-- ****
 $f = "-f eMail\@MyDomain.com"; #            <-- ****
 $subject = "-subject \"Testing blat\"";
 $body = "-body \"Testing blat\"";
 $server = "-server smtp.MyDomain.com"; #    <-- ****
 $hostname = "-hostname MyHost";
 $u = "-u UserID"; #                         <-- ****
 $pw = "-pw PW!"; #                          <-- ****
 $debug = "-debug";
 $x = "-x \"X-Custom-header: Check it out!\"";
    # Here is where we run Blat.
    # Note, the Perl vars are the same as Blat's paramaters.
    # All the stuff you see Blat return to STDOUT (non error messages to
    # the screen) get put in the $return variable.
 $return = `blat - $to $f $subject $body $server $hostname $u $pw $debug $x`;
 print $return;

</End Perl wrapper code>


Ex - Using Batch to call Blat

 :: Populate all the variables we are going to use
 :: You must change the next 3 values
 set to = "-to eMail\@MyDomain.com"
 set f = "-f eMail\@MyDomain.com"
 set server = "-server smtp.MyDomain.com"
 set subject = "-subject \"Testing blat\""
 set body = "-body \"Testing blat\""
 set debug = "-debug"
 :: Here is where we run Blat.
 :: Note, I named the vars the same as Blat's paramaters.
 blat - %to% %f% %subject% %body% %server% %debug%


History of Blat

Who wrote Blat?

Where did the name Blat come from??

``NO real reason for calling it blat... actually I wanted to call it Blat mainly because Pedro thought it was a ridiculous name. And then because we could say things like 'I'm just going to blat off a quick email to ...' etc...''

--Mark Neal


Maintained by

Created with Vim
Valid HTML 4.01!
Questions or remarks about this site to the This site is Generously hosted by SourceForge.net.
Please use this site and software responsibly.
SourceForge.net Logo