This is what I use to simulate a system call to mailx. You can add it to your collection if you want. PS. I use core perl 5.004_03 on NT --John Cavanaugh # ############################################################################ # # File: mailx.pl # Revision: $Revision$ # # Creation Author: cavanaug@sdd.hp.com # Creation Date: Thu Jun 12 20:38:20 1997 # # Modification $Author$ # Modification $Date$ # # Basic Overview: Emulate mailx on nt # # Comments/Concerns: Not great but it works # # TODO: 1. Add code to prompt for Cc: after message.... # It will require restructuring the logic but the # feel of mailx will then be identical to unix. # 2. Change code so that it reads in message before # opening a connection to the smtp port # 3. Add code to identify if STDIN is a tty/pipe/file # and adjust appropriately when prompting for # Subject and Cc etc. # # ############################################################################ # # Configure this for your local site # my $siteSMTP="xxx.xxx.xxx.com"; my $siteDOMAIN="yyy.yyy.com"; # Dont change anything below this line!!!!!!! # ############################################################################ # Initialization Routines # ############################################################################ use English; use Net::SMTP; # use Getopt::Std # ############################################################################ # Global Variables # ############################################################################ my $PROGNAME="mailx"; my $USAGE=" Usage: mailx [-s Subject] [-f FromAddress] ToAddresses\n"; my $OPTIONS="ds:f:"; my $VERSION='$Revision 1.02$'; $VERSION=~ s/\$//g; my $MODDATE='$Date$'; $MODDATE=~ s/\$//g; my $username=$ENV{'USERNAME'}; $username=~ tr/[A-Z]/[a-z]/; my $userdomain=$ENV{'USERDOMAIN'}; $userdomain=~ tr/[A-Z]/[a-z]/; my $computername=$ENV{'COMPUTERNAME'}; $computername=~ tr/[A-Z]/[a-z]/; my $opt_s,$opt_d,$opt_f; if ( $ENV{'EMAIL'} ) { $opt_f="$ENV{'EMAIL'}"; } else { $opt_f="${userdomain}.${username}\@${computername}.${siteDOMAIN}"; } # ############################################################################ # Parse Command Line # ############################################################################ #getopts($OPTIONS) or die($USAGE); JGetOpts($OPTIONS) or die($USAGE); if ( $opt_d ) { $opt_d=1; } else { $opt_d=0; } if ( $opt_s =~ m/^$/ ) { print "Subject: "; $opt_s=; } # ############################################################################ # Begin main processing # ############################################################################ $smtp=Net::SMTP->new(${siteSMTP}, Debug=>$opt_d); $smtp->mail($opt_f); foreach $toaddress (@ARGV) { $smtp->to($toaddress); } $smtp->data(); $smtp->datasend("From: ${userdomain}\\${username} <${opt_f}>\n"); $smtp->datasend("Subject: $opt_s\n"); $smtp->datasend("To: " . join(", ",@ARGV) . "\n"); $smtp->datasend("X-Mailer: pmailx [WindowsNT] \n"); $smtp->datasend("Comment: Unverified from address\n"); $smtp->datasend("\n"); while () { last if m/^\.$/g; $smtp->datasend($_); } # Message End $smtp->dataend(); # Close connection with smtp port $smtp->quit; # ############################################################################ # Functions # ############################################################################ # ############################################################################ # # Function: JGetOpts # # Creator: cavanaug@ecn.purdue.edu (John P Cavanaugh) # Date: Fri Apr 7 20:10:37 1995 # # Basic Overview: Provide a superset of functionality to standard # supplied Getopts. The only enhancement is that # the overwriting of arguments can be changed to # appending instead. # # Example: JGetOpts('a:bcd='); # # -a & -d takes argument. # -b & -c do not take argument. # Sets opt_* as a side effect. # In -a case arg written to opt_a # In -d case arg is appended to opt_d (ENHANCEMENT) # # Returns: Normal error information # # Arguments: $_[0] # Description of options # # Assumptions: # # Comments/Concerns: # # Future Issues: # # ############################################################################ sub JGetOpts { local($argumentative) = @_; local(@args, $_, $first, $rest); local($errs) = 0; local($[) = 0; @args = split( / */, $argumentative ); while (@ARGV and ($_ = $ARGV[0]) =~ /^-(.)(.*)/) { ($first, $rest) = ($1, $2); $pos = index($argumentative, $first); if ($pos >= $[) { if ($args[$pos+1] eq '=') { shift(@ARGV); if ($rest eq '') { ++$errs unless @ARGV; $rest = shift(@ARGV); } eval "if (\$opt_$first) { \$opt_$first .= \":\" . \$rest; } else { \$opt_$first = \$rest; } "; } elsif ($args[$pos+1] eq ':') { shift(@ARGV); if ($rest eq '') { ++$errs unless @ARGV; $rest = shift(@ARGV); } eval "\$opt_$first = \$rest; "; } else { eval "\$opt_$first = 1"; if ($rest eq '') { shift(@ARGV); } else { $ARGV[0] = "-$rest"; } } } else { ++$errs; if ($rest ne '') { $ARGV[0] = "-$rest"; } else { shift(@ARGV); } } } $errs == 0; } # ############################################################################ # $Log$ ------------------------ Something else Attachment ------------------------ Sent: 1997-08-17 12:18:24 From SMTPGATE @POST (cavanaug@sdd.hp.com) : smtp_headers_component Received: by POST.TANDEM.COM (4.14/4.5) id AA25913; 17 Aug 97 12:17:38 -0700 Received: from palrel3.hp.com by suntan.tandem.com (8.6.12/suntan5.970212) for id MAA28036; Sun, 17 Aug 1997 12:18:17 -0700 Received: from hpsdde.sdd.hp.com (hpsdde.sdd.hp.com [15.26.105.103]) by palrel3.hp.com (8.8.5/8.8.5) with ESMTP id MAA24254 for ; Sun, 17 Aug 1997 12:18:11 -0700 (PDT) Received: from hpsdo066 (hpsdo066.sdd.hp.com) by hpsdde.sdd.hp.com with ESMTP (1.37.109.16/15.5+IOS 3.22) id AA161055338; Sun, 17 Aug 1997 12:15:39 -0700 Message-Id: <33F74DA9.CCFBEF45@sdd.hp.com> Date: Sun, 17 Aug 1997 12:14:50 -0700 From: John Cavanaugh Organization: Hewlett-Packard Company X-Mailer: Mozilla 4.01 [en] (WinNT; I) Mime-Version: 1.0 To: CHATTERJEE_ROBIN Subject: Another perl email script for NT........ X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit