# to, from, subject, body, [mailhost]
sub mailit {
my(%mail) = @_;
if($mail{'to'} eq "") { return(0); }
# Set default mail host
if($mail{'host'} eq "") {$mail{'host'} = "yourmail.yourdomain.com";}
my($date) = getdate();
my(%sys) = getplatform();
my($unix) = 1;
if( hay(lc($sys{'os_name'}),"window") ) {
$unix = 0;
}
undef(%sys);
# Decide on a mail program
my($mailprog);
if($unix) {$mailprog="sendmail";} else {$mailprog="smtpmail";}
if($unix) {
open (MAIL, "|$mailprog $mail{'to'}") || die "Can't open
$mailprog!\n";
print MAIL "From: $mail{'from'}\n";
print MAIL "To: $mail{'to'}\n";
print MAIL "Subject: $mail{'subject'}\n\n";
if($mail{'body'} ne "") {
print MAIL "\n".$mail{'body'}."\n";
}
close(MAIL);
} else {
## This is for sending mail on an NT system
## We're assuming that smtpmail is installed and in the path
## This is standard in an MKS env.
## If you do not have MKS you can install blat as an smtp
client.
open(MAIL, "|$mailprog -f $mail{'from'} -h $mail{'host'} -s
\"$mail{'subject'}\" $mail{'to'}\n") || die "Can't open $mailprog!\n";
if($mail{'body'} ne "") {
print MAIL $mail{'body'};
}
print MAIL "\cu\n";
close(MAIL);
} #endif unix
return(1);
}
---
[EMAIL PROTECTED] (Galactic Hero)
Diplomacy: The art of saying good doggie
while searching for a big rock.
> -----Original Message-----
> From: Hill, Ronald [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 07, 2001 10:23 AM
> To: 'Morse, Loretta'; '[EMAIL PROTECTED]'
> Subject: RE: email on win32
>
>
>
> > Does anybody know how to send email via a perl script on a
> > win32 system?
> >
> > Thanks.
> >
> I use the Mail::Mailer module from CPAN
>
>
> use Mail::Mailer;
> $mailer = Mail::Mailer->new("smtp","your.smtp.mail.host");
> $mailer->open({ From => '[EMAIL PROTECTED]',
> To => '[EMAIL PROTECTED]',
> Subject=> 'what you want to say',
> });
>
> print $mailer "$body";
> $mailer -> close;
>
> Hope this helps
>
> Ron