Hi Bill,
I tried what you sent me and get the following:
Can't call method "mail" on an undefined value at test.pl line 24.
When I try the following, it runs but I still don't get any emails:
#!/usr/bin/perl -w
use strict; # not Strict
use warnings;
use Socket;
use Net::SMTP;
#sendmail ('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', "test\n");
#exit;
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
sub sendmail {
#my $from = shift;
#my $to = shift;
#my $msg = shift;
my $from = '[EMAIL PROTECTED]';
my $to = '[EMAIL PROTECTED]';
my $msg = "test\n";
my $smtpserver = 'mail.corp.idt.net'; # do you have a fully qualified name
like:
# mail.idt.net ???
my $smtp = Net::SMTP-> new($smtpserver, Timeout => 10, Debug => 1);
# check debug output for failure indication, then remove Debug arg
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("From: $from\n");
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: Test SMTP\n");
$smtp->datasend("\n");
$smtp->datasend($msg);
$smtp->dataend();
$smtp->quit;
};
Thanks
Liza
-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 05, 2005 8:37 PM
To: Liza Das
Cc: [email protected]
Subject: Re: Perl-Win32-Users Digest, Vol 18, Issue 4
Liza Das wrote:
> Dear Perl Experts,
>
> I'm trying to write something that would send an email if there was an
error
> message.
> But the below script is not working when I do a test run.
> Can you please advise on what I could be doing wrong?
>
>
> #!/usr/bin/perl -w
>
> use Net::SMTP;
>
> use Socket;
> use Strict;
>
> sendmail();
> sub sendmail {
>
> my $smtpserver = 'jerryqa';
> my $smtpuser = 'liza';
> my $fromemail = '[EMAIL PROTECTED]';
>
> my $smtp = Net::SMTP-> new($smtpserver, Timeout => 10);
> $smtp-> mail($smtpuser);
> $smtp-> to('[EMAIL PROTECTED]');
> $smtp-> data();
> $smtp-> datasend("To: [EMAIL PROTECTED]");
> $smtp-> datasend("From: [EMAIL PROTECTED]");
> $smtp-> datasend("\n");
> $smtp-> datasend("test\n");
> $smtp-> dataend();
> $smtp-> quit;
>
> };
Try this one:
use strict; # not Strict
use warnings;
use Socket;
use Net::SMTP;
sendmail ('[EMAIL PROTECTED]', '[EMAIL PROTECTED]', "test\n");
exit;
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
sub sendmail {
my $from = shift;
my $to = shift;
my $msg = shift;
my $smtpserver = 'jerryqa'; # do you have a fully qualified name like:
# mail.idt.net ???
my $smtp = Net::SMTP-> new($smtpserver, Timeout => 10, Debug => 1);
# check debug output for failure indication, then remove Debug arg
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("From: $from\n");
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: Test SMTP\n");
$smtp->datasend("\n");
$smtp->datasend($msg);
$smtp->dataend();
$smtp->quit;
}
__END__
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic
http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs