Hello,
I get the following error when I execute the below script "Can't call method "mail" on an undefined value at ./recalert.plx line 24, <RECCHK> line 9."
I did not write the original perl script, I just modified the email addresses to work in my environment, and the email addresses in the below script are sanitized.
The script has worked for about three years without issue, I really have no perl experience, and not sure what the error means, or how to fix it/
Please help
#!/usr/bin/perl -w
$from = 'email@123.org';
$to = 'email@456.org';
$servername = 'email.789.org';
# $user ='username';
# $pwd ='password';
open RECCHK, "/tmp/statusmon.eml";
@recchkvar = <RECCHK>;
use Sys::Hostname;
my $host = hostname();
my $host1 = uc($host);
open STDERR, '>&STDOUT'; #redirect STDERR output to STDOUT
use Net::SMTP;
$smtp = Net::SMTP->new("$servername", Debug => 1);
### Enable below if authentication required and set parameters above
# $smtp->datasend("AUTH LOGIN\n");
# $smtp->datasend("$user\n");
# $smtp->datasend("$pwd\n");
sleep(2);
$smtp->mail("$from");
$smtp->to("$to");
$smtp->data;
$smtp->datasend("Subject: 79XX/69XXC/WB3 InfiniStream $host1 has an is
+sue, and requires investigation \n");
foreach $line (@recchkvar)
{
$smtp->datasend("$line\n");
}
close RECCHK;
$smtp->dataend;
$smtp->quit
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|