I've replaced my use of Blat with the following script. It works with
Exchange 5.5 AND my ISP's Sun boxes.
Replace the addresses with the ones you need.
______________ cut here ____________________________________________
use Win32;
use IO::Socket qw (:DEFAULT :crlf);
# We use $CRLF (\015\102) instead of \n because Exchange doesn't
# work correctly due to the dos/Unix CRLF vs. new line issue
#----------------------------------------------------------
# Return address for the message
my $FromAddr ='[EMAIL PROTECTED]' ;
# Put each TO address on it's own line
my @ToAddr= qw(
[EMAIL PROTECTED]
) ;
# single quote the mail servername or escape ( \ ) each period
my $MailSrv='mail.peweb.nl' ;
my $sub="Perl automated SMTP mailinge" ;
#----------------------------------------------------------
# If there's no message file provided quit
my $FailMsg= "Useage:$CRLF perl -w $0 <filename>$CRLF";
$MsgFile=$ARGV[0] or Win32::MsgBox("$FailMsg$!",48) && die ;
# Open the message and store the data
open (FILE,"<$MsgFile") or die "Can't open file: $MsgFile$CRLF" ;
@MailData=<FILE> ;
close (FILE) ;
#----------------------------------------------------------
# Open a socket connection to the mail port
my $sock = new IO::Socket::INET (
PeerAddr => $MailSrv,
PeerPort => '25',
Proto => 'tcp',
) ;
die "Could not create socket on port 25: $!$CRLF" unless $sock;
recv ($sock,$back,127,0) ;
print "We opened a socket. Host replied $CRLF $back$CRLF" ;
#----------------------------------------------------------
# Send the standard greeting: HELO
print $sock "HELO BDUNCAN$CRLF" ;
recv ($sock,$back,127,0) ;
print "We sent HELO$CRLF Host Said: $back$CRLF" ;
# Send a reply to address (Who the message is from)
print $sock "MAIL FROM:$FromAddr $CRLF" ;
recv ($sock,$back,127,0) ;
print "We sent MAIL FROM: $FromAddr $CRLF Host Said: $back$CRLF" ;
#-----------------------------------------------------------
# loop through all the email addresses
foreach my $ToAddr(@ToAddr){
print $sock "RCPT TO:$ToAddr $CRLF";
recv ($sock,$back,127,0);
print "$back $CRLF";
}
# Now handle the formal stuff... tell the host that the
# DATA portion is being sent
print $sock "DATA$CRLF";
recv ($sock,$back,127,0) ;
print "We sent DATA$CRLF Host Said: $back$CRLF" ;
# This gives us a subject line... it's optional
print $sock "Subject:$sub$CRLF" ;
# This is optional but makes the message look nice because
# without it there won't be any name(s) in the TO: field
# of the client (eg. Outlook)
foreach $ToAddr(@ToAddr){
print $sock "To:$ToAddr$CRLF" ;
}
# Exchange needs a blank line before the real body
# without it you'll get bad results
print $sock "$CRLF" ;
# Now write each line of the message file
foreach my $MailData(@MailData) {
print $sock "$MailData" ;
}
# in Unix this would be a "." by itself on a line
# but Exchange has a documented bug that requires
# a blank line before and after the end .
print $sock "$CRLF.$CRLF";
recv ($sock,$back,127,0) ;
print "We sent . to end the message $CRLF Host Said: $back$CRLF" ;
print $sock "QUIT$CRLF" ;
recv ($sock,$back,127,0) ;
print "We sent QUIT $CRLF Host Said: $back$CRLF" ;
close($sock) or die "Can't close socket connection. $CRLF" ;
______________ cut here ____________________________________________
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of PeWeb.NL
Sent: Friday, December 01, 2000 12:01 PM
To: [EMAIL PROTECTED]
Subject: RE: ActivePerl digest, Vol 1 #209 - 7 msgs
Importance: High
Hello,
does someone have a mailscript for NT Perl?
Mail program on server is Blat.
I tryed everything with standard form processors, bur all the time i get the
errors from Unix.
Please if you have send it to [EMAIL PROTECTED]
This is very urgent, because my site is down thanks to the tranfer from Unix
to a NT 4.0 server.
Thanks for helping me,
Mrs. Lidia Peters
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl