| Author |
problems using net smtp
|
|
| rjngh2005@gmail.com 2006-10-30, 7:03 pm |
| I have downloaded the libnet module from ActiveState ppm2 repository
next I rebooted my computer
I have checked and have found the following files
c:\perl\lib\net\smtp.pm
c:\perl\site\lib\net\smtp.pm
I give below the part of the email perl code
use warnings;
use strict;
email();
sub email
{
use Net::SMTP;
my $ServerName = "ip_address" ;
$smtp = Net::SMTP->new($ServerName) ;
$smtp->mail('someemail@myserver.com');
The error message I recieve is as follows
Global symbol "$smtp" requires explicit package name at test1.pl line
13.
Please help
Thanks
| |
| Paul Lalli 2006-10-30, 7:03 pm |
| rjngh2...@gmail.com wrote:
> I give below the part of the email perl code
>
> use warnings;
> use strict;
>
> email();
>
>
> sub email
> {
> use Net::SMTP;
> my $ServerName = "ip_address" ;
>
>
> $smtp = Net::SMTP->new($ServerName) ;
>
> $smtp->mail('someemail@myserver.com');
>
>
>
> The error message I recieve is as follows
>
> Global symbol "$smtp" requires explicit package name at test1.pl line
> 13.
You didn't declare $smtp
Stick the word 'my' right before the first time '$smtp' is mentioned.
Paul Lalli
| |
| rjngh2005@gmail.com 2006-10-30, 7:03 pm |
|
Paul Lalli wrote:
> rjngh2...@gmail.com wrote:
>
>
> You didn't declare $smtp
>
> Stick the word 'my' right before the first time '$smtp' is mentioned.
>
> Paul Lalli
This is on a Windows 2000 desktop.
I have activestate perl installed
using ppm I have downloaded the libnet module from ActiveState ppm2
repository
next I rebooted my desktop.
I have checked and have found the following files
c:\perl\lib\net\smtp.pm
c:\perl\site\lib\net\smtp.pm
I guess you have to compile this on a unix box
but I am not sure if you have to compile this on a Windows 2000
desktop.
The code is given below.
use warnings;
use Net::SMTP;
$server = 'ip_address';
$to = 'abc@test.com';
$from_email = 'abc@test.com';
$subject = 'hello, email';
$smtp = Net::SMTP->new($server);
$smtp->mail($from_email);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("Subject: $subject\n\n");
$smtp->datasend("This will be the body of the message.\n");
$smtp->datasend("\n--\nVery Official Looking .sig here\n");
$smtp->dataend();
$smtp->quit();
print "done\n";
The error message is as below
Can't call method "mail" on an undefined value at test2.pl line 8.
Please help
|
|
|
|