MailBatch - if you do not have the time!

Visit MaiBatch at sourcforge.net

Contents


MailBatch News

Release 1.0.4 of MailBatch is now available for download. New features are:

Release 1.0.2 of MailBatch include:

Download MaiBatch release 1.0.2


Introduction to MailBatch

MailBatch is a simple email client that can be used to send emails to a large number of users from the command line. Email information are retrieved from a csv file that can include email data that is needed to customize the email based on the receiver. In the example of a course registration acknowledgment where different recipients will receive different information based on their identity. So to compose the batch emails you need a csv formated email data file, called address, a file with the email body content and a subject. The address file can typical be created by some business system and should be in a csv formated file like:
lars@hightech.com, Lars Larsson, 2/4, Advanced Unix training
bert@beginner.com, Bert Bertson, 5/4, Unix beginners


The first column must always be the email address to the recipient. The other columns are optional and can include user specific information. The different fields can be inserted in the subject, body and signature parts by using the string {X} where X is the number of the column in the csv file. X=0 is the first column that are the email recipient address.

The body file for this course registration example could look like this:
Dear {1},
We are happy to invite you to our course in {3} starting the {2}-2006.
Best regards,
HeadMaster

In the above file the {x} is references to the fields in the address csv file where {0} is the first field that should always be the email address. The rest of the fields are optional.

To send out emails to the new pupils just run
java MailBatch -address my.csv -body my.body -subject Welcome -from headmaster@unixuni.net -smtp smtp.unixuni.net

The program works with the following parameters
The recipients address are stored in a csv file. The first column is the email address. The file can have more fields that can be used depending on needs, i.e. the real name.
-address address-file
If the -address switch is not set the address data are read from stdin

The program can have a fixed subject that is common to all recipients that are given on command line.
-subject string (mandatory)
or:
-subjectfile filename (mandatory)
If reading the subject from a file only the first line is used as a subject.

Every messages can have a body text that is in text/html; charset=ISO-8859-1
-body body-file
If the body file include {x} these are replaced with fields from the address-file

Attachment file(s) can be attached to a message using -attach. To attach multiple file the following syntax must be used:
Example 1:
-attach fileone,~/filetwo
The character , must be used to separate the file and no space are allowed at the comma or in the filename.
Example 2:
-attach "file one.pdf , file two.pdf"
Use " to enclose the multiple file names. Now space is allowed but you can not use shell directives or shell parameters since expansion of these will not work.

From must be set to a email address
-from user@address

If the reply address should be different from the from address
-replyto replyto

Sender info can be put in a signature file that is append to the body
-signature signature-file

Logging is done by setting
-logfile logfile
Logfile can have the $T tag in the name. This will be replaced to the current timestamp to easily separate different logfiles.

To pause between each mail sent
-pause X
Where X is the pause in seconds. Default is 5

Turn on visual progress of the sent emails. A dot (.) means successfully sent, question mark means not sent and a bang means failed.
-verbose

To verify the content of each email before it sent use the switch
-verify

Supported properties are:
signature - file name to signature file
logfile - file name to log file
from - the from user email address, i.e. don@xyz.com
replyto - the reply to email address if different the the from user
smtp - the smtp server address, i.e. smtp.chello.se
verbose - show mail sending progress, default is false
pause - the pausing interval between sending emails, default is 5

Properties should be put in the file mb.properties. Valid locations are user home directory or current working directory.


System requirements

Requirements:
To run MailBatch the following jars are requiered:
- JavaMail 1.4 from java.sun.com
- JavaBeans Activation Framework (JAF) 1.1 from java.sun.com
- Commons CLI 1.0 from apache.org

Installation

On Linux
Set REQLIB to where your have your jars that are specified in the System requirements section.
$ export REQLIB=your_jar_dir
$ tar xzvf mailbatchX.Y.Z.tar.gz
$ cd mailbatchX.Y.Z
Run Mailbatch:
$ java -classpath $REQLIB/commons-cli-1.0.jar:$REQLIB/activation.jar:$REQLIB/mail.jar:. MailBatch -help

On Windows
Set REQLIB to where your have your jars that are specified in the System requirements section.
c:\> set REQLIB=your_jar_dir
c:\> unzip mailbatchX.Y.Z.zip
c:\> cd mailbatchX.Y.Z

Run MailBatch:
c:\mailbatchX.Y.Z> java -classpath %REQLIB%\commons-cli-1.0.jar;%REQLIB%\mail.jar;%REQLIB%\activation.jar;. MailBatch -help

Download

Download MaiBatch from sourceforge.net