net smtp help

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

This is on a Windows 2000 desktop.

I have activestate perl installed

using ppm I have downloaded the libnet module from ActiveState ppm2

next I rebooted my desktop.

I have checked and have found the following files


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

The code is given below.

use warnings;
use Net::SMTP;
$server     = 'ip_address';
$to         = '';
$from_email = '';
$subject    = 'hello, email';
$smtp = Net::SMTP->new($server);
$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");
print "done\n";

The error message is as below

Can't call method "mail" on an undefined value at line 8.

Please help

Re: net smtp help wrote:
Quoted text here. Click to load it

I doubt the need to compile - in fact, Active State's PPM packages are
supposed to be already compiled when you get them.

What "Can't call method xyzzy on an undefined value" means is that you
didn't get a Net::SMTP object back from the "new()." In general you
should _always_ check when you instantiate an object if there is any way
  the instantiation could fail. And in general when you see this message
you should assume the instantiation failed, and investigate along those

Unfortunately, the Net::SMTP docs are less than clear on how you can get
a useful error. Two good places to look are always $! and $@. So:

Quoted text here. Click to load it

$smtp = Net::SMTP->new ($server) or die <<eod;
Error - Failed to create Net::SMTP object
         $! = $!
         $@ = $@

Quoted text here. Click to load it

When I do this, I get

Error - Failed to create Net::SMTP object
     $! = Invalid argument
     $@ = Net::SMTP: Bad hostname 'ip_address'

Which in retrospect is obvious.

The trick is, what server do you give it? If it's not, it will
have to have routing enabled, which will plunge you into the wonders of
configuring SMTP servers. Good luck.

Tom Wyant

Re: net smtp help

harryfmudd [AT] comcast [DOT] net wrote:
Quoted text here. Click to load it

Your input helped a lot!!!!

I added the code (section for die...eod)
and got the message unable to create object.

I consulted my network admin and he explained that the smtp host was
configured to allow only email from certain ip addresses and of course
my desktop was not in the list.

Hence to test things out we added my desktop ip address to the list and

Bingo.....everything worked.
I am a happy enlightened person.

Thanks a lot for pointing me in the right direction !!!!!

You have made my day

Site Timeline