Shell xmpMail.pl to send mails via sendmail
The following script references „Perl module xmpPerl.pm – function package used by DBA Perl scripts“
The following very simple script is just a small frame for sending mail via network from command level or as a service for other scripts.
#!/usr/local/bin/perl -w
################################################################################
# xmpMail - send text as email so single ID's or distriubtion lists
# Called by - Command Level
# Calls - xmpPerl.pm - DBA Perl Package
# Getopt - Argument-Verwaltung
# Optionen - xmpLOG.PL -a appl -v verteiler/file -t text/textfile
#-------------------------------------------------------------------------------
# Autor - GR /03.12.01 - V1.0 first version
# - GR /11.12.01 - V1.1 small enhancement
#-------------------------------------------------------------------------------
# Comments This script uses an associated function from function library
# xmpPerl.pm. It sends an email from parameter input or a file input
# to a single email address or distribution list with a number of
# email id's.
# Text input or distribution lists, which are composed of several
# words should be quoted (").
################################################################################
# Modules ######################################################################
use strict;
use Getopt::Std;
use vars qw($opt_a $opt_v $opt_t);
use xmpPerl;
my $rc;
my $rl;
my $VER = "1.1";
# check arguments/options prüfen ###############################################
getopts("a:v:t:");
if ( (! defined $opt_a ) # Application
or (! defined $opt_v ) # Verteiler/File
or (! defined $opt_t ) ) { # Text/File
SaySyntax()
}
################################################################################
# call function form function library
################################################################################
$rl = xmpPerl::MailText($opt_a,$opt_v,$opt_t);
$rc = $?;
################################################################################
# give some information
################################################################################
if ($rc != 0) {
print "$0 failed to create/send email using $opt_v $opt_t ($rc).\n"
}
print "email has been sent to\n$rl\n";
exit 0;
#################################################################################
########################################################## Sub Routines #########
# SaySyntax #####################################################################
sub SaySyntax {
die "Usage: [perl] $0 -a ... -v ... -t ...\n".
" -a application, name of process, stream, jobs, unit, ...\n".
" -v email id's or filename with distribution list\n".
" -t text or name of a text file\n".
" abends ";
}
For more information how to send emails via sendmail (on AIX) see here: „Fun with Sendmail on AIX“ (IBM developerWorks 2010, PDF).



Comments
Comments are closed.