in reply to Seeking tutelage

For Problem #1, take a look at Mail::Sender. It has nice attachment support. Here's a script I wrote for some people here about two years ago that's gotten lots of mileage. I've X'ed out one or two things that are ours, but they're fine points that would be good exercises.

#!/usr/local/bin/perl =head1 NAME mailfiles - General purpose command line mailer supporting attachments =head1 SYNOPSIS B<mailfiles -f from -t to [-du] [-c cc] [-h smtp_host] [-m message] [- +r reply_to ] [-s subject] [file ...]> =head1 REQUIRED OPTIONS =over 4 =item -f from Specifies the from email address as I<from>. =item -t to Send the mail to I<to>, where I<to> is one or more email addresses. M +ultiple addresses should be comma separated and quoted if spaces or special sh +ell characters appear in the addresses. =back =head1 OPTIONAL ARGUMENTS =over 4 =item -c cc Copy one or more email addresses specified by I<cc>. Multiple email a +ddresses must be comma separated and need to be quoted if spaces or special she +ll character appear in them. =item -d Convert all specified file attachments to DOS I<CR/LF> format before attaching. Note that the attached files are modified if this option i +s specified. This is only meaninful if the attached files are text f +iles in UNIX format and the message is being sent to a DOS/Windows client. =item -h smpt_host Use I<smpt_host> as the mail server. Defaults to the B<GSI> corporate + mail server if not specified. =item -m message Put the text specified in I<message> in the sent message body. Needs +to be sent quoted from the shell if whitespace or special characters appear +in it. =item -r reply_to Set the reply to address to I<reply_to>. =item -s subject Set the message subject to I<subject>. =item -u Convert all specified file attachments to UNIX newline format before attaching. Note that the attached files are modified if this option i +s specified. This is only meaninful if the attached files are text file +s in DOS/Windows format and the message is being sent to a UNIX client. =item file ... File(s) to be sent as attachments. =back =head1 AUTHOR Me =cut use strict; use Mail::Sender; use Getopt::Std; use XXX::File::TextConvert; # DOS/UNIX file conversions use vars qw/$opt_c $opt_d $opt_f $opt_h $opt_m $opt_r $opt_s $opt_t $o +pt_u/; my $mail_opts = { smtp => 'XXX.XXX.XXX.XXX', msg => ' ' }; my $message; my $from; my $to; my $cc; my $subject; sub parse_opts { getopts("c:df:h:m:r:s:t:u"); die "Required -f (from) value missing.\n" if (!defined($opt_f)); die "Required -t (to) value missing.\n" if (!defined($opt_t)); die "Only one of -d or -u makes sense.\n" if ($opt_d && $opt_u); $mail_opts->{from} = $opt_f if ($opt_f); $mail_opts->{smtp} = $opt_h if ($opt_h); $mail_opts->{to} = $opt_t if ($opt_t); $mail_opts->{subject} = $opt_s if ($opt_s); $mail_opts->{msg} = $opt_m if ($opt_m); $mail_opts->{cc} = $opt_c if ($opt_c); $mail_opts->{replyto} = $opt_r if ($opt_r); if (scalar(@ARGV) > 0) { unix_to_dos(@ARGV) if ($opt_d); # You write this dos_to_unix(@ARGV) if ($opt_u); # You write this $mail_opts->{file} = join(',', @ARGV); } } sub send_mail { my $sender = new Mail::Sender() or die "Can't create mail sender object: $!\n"; defined($mail_opts->{file}) ? $sender->MailFile($mail_opts) : $sender->MailMsg($mail_opts); } parse_opts(); send_mail(); exit 0;