Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - lsbounced

NAME

lsbounced - lists the original addressees of returned e-mail.

SYNOPSIS

lsbounced [[ -c <cc_addr> ] [ -d ] [ -L <mail_box_directory> ] [ -l ] [ -r <e-mail_recipient> ] [ -s ] [ -v ] [ -x <xclude_addr> ] <mailbox> ] | [ -V ]

AVAILABILITY

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

DESCRIPTION

This utility was written for a company which was receiving a substantial amount of bounced email after each mailout to it's clienT list.

lsbounced uses " ssh " to connect to an IMAP server and collects the addresses found in the nominated mailbox using the local the file system. (NB. It is not possible to just use the "From:" address as this is usually the recipient mail hosts "postmaster".)

The addresses are cleaned up using " sed " and turned into a sorted list of unique addresses. The utility optionally formats the list using " groff " and " ghostview " to produce a "pdf" file which can be presented on screen and e-mailed to specified recipients.

OPTIONS

-c <cc_mail_address> The -c    option is used to add cc addresses to which a copies of the report sent with the -r    option should be sent. This may be a single address or a comma separated list. The option is only relevant when the -r option is also used.

-d    Set debug mode on. The -x    option is set within the shell and each command in the script is echoed to the console.

-L <directory> The directory under which the mail messages are stored. " lsbounced " expects that the " Courier " imap server is being used with virtual mailboxes and that each message is in a separate file.

-l    Use the local syslog facility to log that lsbounced has been run and record the number of messages found and the number of unique address extracted.

-r <recipient_addr> Send out the list with a covering letter to the <recipient_addr> .

-s    Use " gv " to show the list on screen in pdf format.

-v    Set verbose mode on. (Frankly verbose is somewhat of an exageration).

<mailbox> The mail account to be examined.

-V    Print the version details and exit.

FILES

/var/qmail/mailnames/<mail_domain>/<virtual_user_name>/Maildir/{cur,new}

EXAMPLES

lsbounced -s -r fulford@fulford.net -L /var/qmail/mailnames bounced.westbridgford.ingo

Use ssh to access mailserver.neg.uk. Count then number of message file in the directories /var/qmail/mailnames/westbridgford.info/Maildir/{cur,new}. Pass the messages through awk and sed filters to extract the original mail addresses to which the bounced messages were sent.

Use groff and ps2pdf to format the results and present a pdf file to screen. Send a copy of the report to fulford@fulford.net.

BUGS

The script is quite crude and has very little, if any, error checking. The consequences of unexpected input are untested.

SEE ALSO

chkmail, msg_cnt, msg_del.

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.