Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - mailout

NAME

mailout - sends personalised html email to a number of recipients.

SYNOPSIS

mailout [ -c <config_file> ] [ -d ] [ -n # records ] [ -t ] [ -v ] [ -x ] [ -X <exclude_file> ] [ <message_file> ]

AVAILABILITY

mailout is a Bourne shell script and should work equally well on all versions of UNIX, Linux and Mac OS X.

DESCRIPTION

The script mailout extracts names and email addresses from a csv data file and uses awk to generate personalised html email to each recipient in the list. Sendmail is is used as the MUA and the "from" address is set in the script.

If the -n option is used (see options below) the number of emails may be restricted.

The script keeps track of the recipients to whom the message has been sent and the next time it is run skips those records and sends messages to new addresses only.

The default data file is /var/mailout/data.csv . This may be changed in the configuration file.

The default message file is /var/mailout/msg but this is normally changed by specifying the file on the command line. Mailout does not care if the message is in html format or not.

OPTIONS

-c <config_file> The default configuration file is /usr/local/etc/mailout.cf , this may be changed on the command line by using the -c    option.

-d    Set debug mode on. The script will report its progress to screen as it runs.

-t    Sets test mode. The script runs through all its usual actions and reports recipient details as it would normally but the email is actually sent to a single email address under the control of the user. This is to allow verification by inspection of the resulting message content.

-v    Set the operation mode of the script to verbose. In verbose mode mailout will echo to screen the recipient details for each message sent.

-x    With the -x    option set the recipients that would otherwise be contacted are extracted and reported to screen but no mail is sent. This is useful where is desirable to to check the potential recipients or cross reference with other mailouts before committing to sending the message.

-X <exclude_file> The -X    option allows an exclude file to be specified on the command line. The default exclude file is /usr/local/etc/mailout.xcld , although this may be changed using the configuration file. The exclude files are lists of mail addresses and mail domains to which mail should not be sent. Both files will be consulted if the -X <exclude_file> option is used.

EXAMPLES

mailout -n 20 -v  ad010429.html

Send personalised email using the file ad010429.html to the next 20 recipients from the /var/mailout/data.csv .

List the recipients to screen as each email is sent.

BUGS

Not really bugs but the script has very little input error checking.

The fields for the recipient names and email addresses are hardwired as are the strings that are to be substituted in the message file, ie. "rcpt" and " firstname ".

The from address is also hardwired.

FILES

/usr/local/etc/mailout.cf, /var/mailout/data.csv, /var/mailout/deleted.csv, /var/mailout/mailout.xcld.

AUTHOR

Clifford W Fulford, City Linux. Contact fulford@fulford.net or +44 (0)709 229 5385.


The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.