

  
Thursday, December 15th, 2005
 

Universal Serial Bus  Embedded Internet  Legacy Ports  Device Drivers  Miscellaneous  



Command Line SMTP Mailer for Batch Jobs 


Bmail is a free but lean command line SMTP mail sender. Don't get fooled into playing $$$ for huge executables. Bmail allows the user to automate the sending of email messages containing log files, data downloads or error messages on Win32 based computers. Together with the freeware utility mpack, you can also send MIME encoded attachments. 

	C:\>bmail -s mars -t cpeacock@max -f root@neptune -h -a "Data Download Script
	is not Working Correctly" -b "The script on neptune has stopped getting data"

	Command Line SMTP Emailer V1.07
	Copyright(C) 2002-2004 Craig.Peacock@beyondlogic.org
	Opening connection to mars [192.168.0.10] on port 25
	220 mars ESMTP Postfix (Release-20010228)
	250 Ok: queued as 04168186A7

Bmail has the following options - 

	C:\>bmail /?

	Command Line SMTP Emailer V1.07
	Copyright(C) 2002-2004 Craig.Peacock@beyondlogic.org
	Usage: bmail [options]
	        -s    SMTP Server Name
	        -p    SMTP Port Number (optional, defaults to 25)
	        -t    To: Address
	        -f    From: Address
	        -b    Text Body of Message (optional)
	        -h    Generate Headers
	        -a    Subject (optional)
	        -m    Filename (optional) Use file as Body of Message
                -c    Prefix above file with CR/LF to separate body from header
                -d    Debug (Show all mail server communications)

The mail server name, To: Address and From: Address fields are mandatory. Multiple recipients can be specified after the -t by separating them by a comma. The SMTP port number is seldomly used, but can be used to force mail to be sent to a non standard port. The user has two choices for specifying the body of the message. If a single line body is all that is required, it can be specified on the command line using the -b option. In this case you may want to also use -a to specify a subject and -h to add TO: and FROM: headers to the body of your message. 

However if a larger message body is required, such as a pre-formatted text email, log file, data file or a mime encoded attachment etc then the body of the message can be read from a file. The file can be specified by the -m switch. In this case the user can choose to use the -h, -a and -b switches in conjunction with the file, or manually enter these headers to the top of your file. 

Usage Examples 
Below are just some examples showing the use of bmail. 

If you simply need to send a quick one line email you can use the following example, 

	C:\>mail -s smtp.server -t cpeacock@max -f root@neptune -h -a "Subject e.g. Fatal Error" 
	-b "Body of message e.g. Fatal Error occurred in cgi script, secure.cgi"

	Command Line SMTP Emailer V1.07
	Copyright(C) 2002-2004 Craig.Peacock@beyondlogic.org
	Opening connection to mars [192.168.0.10] on port 25
	220 mars ESMTP Postfix (Release-20010228)
	250 Ok: queued as B952E42C6F

Pipes can be utilised to redirect stdout from a process(s) to a log file, then send this file as the body of the message should an error result. 

	C:\>[ Some Process ] > stdout.txt
	C:\>if errorlevel 1 bmail -s smtp.server -t cpeacock@max -f root@neptune -h -a "Process
	Dump" -m stdout.txt -c

	Command Line SMTP Emailer V1.07
	Copyright(C) 2002-2004 Craig.Peacock@beyondlogic.org
	Opening connection to mars [192.168.0.10] on port 25
	220 mars ESMTP Postfix (Release-20010228)
	250 Ok: queued as 4AFD1186B7

Note should be taken of the -c switch which separates the body from header with a CR/LF combination. While with most mail clients it doesn't make any difference, some versions of Outlook will display an empty body, treating your stdout.txt body as part of the header. 

With mpack you can use bmail to send mime attachments. 

	C:\>echo Please find attached today's build of mail.exe > body.txt
	C:\>mpack -s "Today's Build" -d body.txt -c application/exe -o body.msg mail.exe
	C:\>bmail -s smtp.server -t cpeacock@max -f root@neptune -h -m body.msg

	Command Line SMTP Emailer V1.07
	Copyright(C) 2002-2004 Craig.Peacock@beyondlogic.org
	Opening connection to mars [192.168.0.10] on port 25
	220 mars ESMTP Postfix (Release-20010228)
	250 Ok: queued as 485CB186A7

Download 

Version 1.07, 17K bytes. (Freeware) 


Revision History 
3rd May 2004 - Version 1.07 
Fixed daylight saving bias problem in date headers. 
Fixed problem where bmail would not exit on all errors such as 552: Mail Box Exceeds Limit etc. 
22nd February 2004 - Version 1.06 
Added the current time and date to the headers (-h switch). 
Modified the parsing of the to: and from: email addresses to improve compatibility. 
28th February 2003 - Version 1.05 
Feedback from Outlook/Exchange users V1.04 confirmed fixes non display of body. Yay, but. . Broke MIME Encoded Attachment functionality in the process. 
Added -c switch to control the CRLF prefixing the body. 
25th February 2003 - Version 1.04 
Prefixed body with extra CRLF to assist MS Outlook in displaying correct body of message. 
24th February 2003 - Version 1.03 
Prefixed body with extra CRLF to assist MS Outlook in displaying correct body of message. 
Fixed "unknown" server name problem in response to HELO. 
2nd February 2003 - Version 1.02 
Added hidden -d (debug) switch to options. This displays all transactions with the mail server to the screen or you can pipe it to a file. 
19th December 2002 - Version 1.01 
Increase buffer size to allow compatibility with a wide range of mail servers. 
16th December 2002 - Version 1.0 
First release to public. 


Other Unique and Innovative Software Solutions from Beyond Logic 
Trust-No-Exe - An executable filter for Windows NT/2000/XP 
Allow users to run trusted applications from defined directories, while preventing the execution of non-trusted programs from floppy disk and CDROM drives or from the users e-mail attachment directory. Stop PE viruses in their tracks where on Windows platforms year, nine out of ten of the top viruses were spread via e-mail. 


Command Line Process Viewer/Killer/Suspender for Windows NT/2000/XP 
Want a command line utility to view, kill, suspend or set the priority or affinity of processes, perhaps from a batch file? Kills rouge processes where Window's Task Manager fails. 


BeyondExec - Spawn Processes and/or Shutdown Remote Windows NT/2000/XP WorkStations. 
Have you ever wanted to run a process such as an application installer, service pack, virus signature update etc or shutdown a single or group of remote computers without having the burden of installing any remote client on your target computers? 


Delete/Copy by Owner utility for Windows NT/2000/XP 
Have you ever had the need to find, copy or delete files that were owned by a certain user? A great way to back up files created by previous employees or to clean workstations when one leaves. 


PortTalk - A Windows NT/2000/XP I/O Port Device Driver 
A problem that plagues Windows NT/2000/XP, is it's strict control over I/O ports. Unlike Windows 95, 98 or ME, Windows NT/2000/XP will cause an exception (Privileged Instruction) if an attempt is made to access an I/O port that your program is not privileged to access. The PortTalk driver allows existing programs to access selected I/O ports. 


Console Computer Information Utility for 2000/XP 
Want a quick console utility to display the hardware specifications of a PC including Processors Type, Operating System and Service Pack, Physical and Virtual Memory, Network Addresses, Logical Drive information, Video Card Type, Hard Disk, CDROM and Printer Information. 


SMART & Simple for NT/2000/XP 
A small and simple utility to instantly view the SMART (Self-Monitoring Analysis and Reporting Technology) attributes of Hard Disk Drives without first requiring installation. 


 

Copyright 2002-2005 Craig Peacock - 15th June 2005. 


USB in a Nutshell - IntroductionUSB in a Nutshell - HardwareUSB in a Nutshell - USB ProtocolsUSB in a Nutshell - Endpoint TypesUSB in a Nutshell - USB DescriptorsUSB in a Nutshell - USB RequestsUSB in a Nutshell - EnumerationPIC16F87x and PDIUSBD11 USB ExampleUSB 1.1 Integrated CircuitsUSB 2.0 Integrated CircuitsUSB Protocol AnalysersUSB Device Driver DevelopmentUSB with the simplicity of RS-232On-The-Go Supplement - Point-to-Point Connectivity for USB.ISP1161 Host Controller for Embedded SystemsPDIUSBD11 USB InterfaceWin 2000/XP Driver for DeVaSys USBLPT-PD11 USB BoardsUSB Driver for the Cypress USB Starter KitLinksEthernet & TCP/IP InterfacesEmbedded Linux, Setting up the Development EnvironmentEmbedded Linux, Understanding the Build ToolsEmbedded Linux, Building gcc-2.95.3 m68k-elf for uClinuxEmbedded Linux, BFLT Binary Flat FormatExploring the Netcomm NB5LinksStandard Parallel Port (SPP)Enhanced Parallel Port (EPP)Extended Capabilities Parallel Port (ECP)Parallel Port Debug ToolParallel Port LCD Interface ExampleRS-232 Hardware & Software RegistersRS-232 Low Level Programming & External HardwareUsing Interrupts (PC)Interfacing Example - Analog Sampling Via the RS-232 PortInterfacing Example - Connecting a LCD Module to the RS-232 PortQuick and Simple RS-232 TerminalRS-232 Protocol AnalyserLinksPortTalk - A Windows NT I/O Port Device DriverUniversal Serial Bus Device Driver Development Interrupts and Deferred Procedure Calls on Windows NT4/2000/XP USB Driver for the Cypress USB Starter KitDevice Driver Fiddler (tools)Windows NT Device Driver Installer (tools)Device Driver Remover Win9x (tools)LinksCMOS Digital Image Sensors and LensesGenerate Ring Tones on your PIC16F87x MicrocontrollerInterfacing the AT KeyboardHow does the Microchip ICD Work?Trust-No-ExeCommand Line Process Viewer/Killer/Suspender for Windows NT/2000/XPBeyondExec - Spawn Processes on Remote Windows NT/2000/XP WorkStationsBeyond Logic Shutdown Utility for NT/2000/XPBmail - Command Line SMTP Mailer for Batch JobsDelete/Copy by Owner utility for Windows NT/2000/XPWin32 Pipe Security Editor Windows NT/2000/XPConsole Computer Information Utility for 2000/XPSMART & Simple for NT/2000/XPKodak DC215 Support and FAQSouth Australian Electricity GenerationLinks