When you make your call to Net::SMTP->new you should test the object
returned.
I believe that if you have errors or there are problems with configuration
information you send to Net::SMTP (could be network problems etc.) the
Net::SMTP object will return (undef). (check the docs to confirm, it may
return 0).

So perhaps you should add:-
my $smtp = Net::SMTP -> new ("luxn.com");
unless (defined ($smtp))
{
    die "Cannot create SMTP object -check your configs!";
}
$smtp -> mail($optFrom);

or maybe even

my $smtp;  #(you should definitely make this a local variable)
unless ($smtp=Net::SMTP->new("luxn.com"))
{
    die "Cannot create SMTP object -check your configs!";
}
$smtp -> mail($optFrom);

The error message you are getting is the standard perl error (I think)
When you make a call to the ->mail() function perl expects the $smtp to be a
reference to an Object (which might even be even more simply a reference to
a hash?). If the hash (or is that hash rererence) isn't defined then when
you call $smtp->mail  you are asking perl to access the hashref (mail) which
is  held in the hashref ($smtp). But as $smtp doesn't exist, perl sensibly
tells you you're trying access the 'method' - the special name for a
subroutine of an object hashref, because $smtp doesn't exist and thus cannot
tell perl where 'mail' is.

Or at least thats kinda how I picture it all in my head - Theres probably a
few people here who can put me straight,

Regards

Marty

----- Original Message -----
From: "Morse, Richard E." <[EMAIL PROTECTED]>
To: "'$Bill Luebkert'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, June 06, 2002 10:46 PM
Subject: RE: Send email in ActivePerl using SMTP


> $Bill Luebkert [mailto:[EMAIL PROTECTED]] wrote:
> > [EMAIL PROTECTED] wrote:
> >
> > > I tried the following to use SMTP to send email:
>
> > >    $smtp = Net::SMTP -> new ("luxn.com");
> > >    $smtp -> mail($optFrom);
> > >
> > > Can't call method "mail" on an undefined value at
> > > mailtest.pl line 8
> > >
> > > line 8 is:    $smtp -> mail($optFrom);
>
> Sorry to pull this through $Bill -- I didn't get the original...
>
> According to the error messages, $smtp isn't properly being defined.  I
have no
> idea whether this affects things or not, but what happens if you get rid
of the
> extra whitespace (ie, write "$smtp = Net::SMPT->new('luxn.com')")?
>
> Also, read the docs for Net::SMTP -- there may be a way to get the error
message
> reported when it can't create the original $smtp...
>
> HTH,
> Ricky
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to