[wellylug] Perl Help
Chris Hodgetts
chris at archnetnz.com
Mon Sep 13 12:16:33 NZST 2004
This may give more indication
if ($passed <1)
{
my
$smtp=Net::SMTP->new('127.0.0.1',(Hello='thismachine.thatdomain.foo.nz'));
$smtp->mail("firstname.lastname\@somedomain.foo.nz");
$smtp->to("firstname.lastname\@somedomain.foo.nz");
$smtp->data();
$smtp->datasend("To: firstname.lastname\@somedomain.foo.nz\n");
$smtp->datasend("Date: $thisday, $thisdate $thismonth $thisyear
$hour:$min\n");
$smtp->datasend("Subject: Server5 Error Report $timestamp\n\n");
$smtp->datasend("Error Report:\n$errorDescription");
$smtp->dataend();
$smtp->quit();
The guy who wrote this script has since left the company, and before he
left we migrated it over to another box, and it has never worked, and he
didnt care...
On Mon, 2004-09-13 at 11:11, Grant McLean wrote:
> On Mon, 2004-09-13 at 10:44, Chris Hodgetts wrote:
> > Hello,
> >
> > I am trying to use perl mail modules, and I think I have installed the
> > correct ones, but clearly not, because I am getting the following error:
> >
> > Can't call method "mail" on an undefined value at
> > /home/test/serv5/testS5.pl line 59.
> >
> > Debian Unstable is the distro I am using, can anyone let me know what
> > packages "Should" be installed for this to work?
>
> Hmm, that message doesn't give us much to go on and it certainly
> doesn't imply that the cause is a missing package.
>
> Presumably line 59 of the script has something like this:
>
> $some_var->mail('some arguments');
>
> The error message is telling us that the variable ($some_var in the
> example above) is empty when the script expects it to contain an
> object of some sort. This in turn implies that an earlier line in
> the script attempted to create an object, perhaps like this:
>
> $some_var = Net::SMTP->new('stmp.some.domain');
>
> And that line is failing for some reason. A better way to write that
> line would have been:
>
> $some_var = Net::SMTP->new('stmp.some.domain') or die "$!";
>
> That way you'd get an error indication at the time of the actual
> failure rather than later on.
>
> My examples assume the Net::SMTP module was being used. This is part
> of the core Perl distribution. In your case, it could well be a
> completely different module - typically included near the start of
> the script with a line like this:
>
> use Net::SMTP;
>
> Cheers
> Grant
>
>
More information about the wellylug
mailing list