Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    103
    Rep Power
    10

    Use Net::SMTP; not working


    I have the command

    use Net::SMTP;

    in my first line, and it fails to load it. The exact error is:

    Compilation failed in require at C:\Inetpub\wwwroot\cgi-bin\mail.pl line 1.
    BEGIN failed--compilation aborted at C:\Inetpub\wwwroot\cgi-bin\mail.pl line 1.
    Do I need to install a specific ppm to use SMTP? If not, what am I missing?
  2. #2
  3. No Profile Picture
    Hang your freedom higher.
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2005
    Posts
    659
    Rep Power
    158
    You shouldn't need to install anything else, can we see your code. The message you're getting seems to indicate a problem with your script in general rather than specifically net::smtp.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    103
    Rep Power
    10

    Great. Thanks for the response.


    Originally Posted by atlantisstorm
    You shouldn't need to install anything else, can we see your code. The message you're getting seems to indicate a problem with your script in general rather than specifically net::smtp.
    Code:
    use Net::SMTP;	
    use CGI qw(:standard);	
    
    my $to = param(to);	#here we retrieve the importan user information
    my $from = param("from");
    my $subject = param("subject");
    my $message = param("message");
    my $mailserve = param("mailserver");
    
    print header;
    print "<h3>The request has been processed.";
    print "Thank You $from</h3>";	
    
    $smtp = Net::SMTP->new($mailserver);	#this creates a new instance of an SMTP server
    
    #for all of the following lines, we use -> which is Perl's scope operator, it's equivalent to the dot operator in JavaScript
    #or C, C++ and Java
    $smtp->mail($ENV{USER});	#sets the user
    $smtp->mail("$to");		#sets the destination 
    $smtp->data();			#this is the clause that the server will actually send real data
    $smtp->datasend("To: $to \n");	#datasend() issues a command to the server. Here we send To: plus the actual value and a newline
    $smtp->datasend("From: $from \n");	#followed by the sender info
    $smtp->datasend("Subject: $subject \n");	#subject
    $smtp->datasend("\n");	
    $smtp->datasend("$message \n");	#the message 
    $smtp->datasend();	#an empty stub
    $smtp->quit;	#and we close the server
    The error message starts with some crap about oracle not loading, but I gather this has to do with the SMTP not loading properly.

    Thanks.
  6. #4
  7. 'fie' on me, allege-dly
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    Location
    in da kitchen ...
    Posts
    12,894
    Rep Power
    6444
    the shebang line appears to be missing, which any webserver should crap on
    #!/path/to/perl typically #!/usr/bin/perl, though you're talking about ppm's so it's safe to assume you're on Doze, perhaps #!/C:/Perl/bin/perl

    Is this to be accessible from a public website, if so, that's a spam relay right there.
    --Ax
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
    BIT COINS ANYONE
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    103
    Rep Power
    10

    Ugh


    Originally Posted by Axweildr
    the shebang line appears to be missing, which any webserver should crap on
    #!/path/to/perl typically #!/usr/bin/perl, though you're talking about ppm's so it's safe to assume you're on Doze, perhaps #!/C:/Perl/bin/perl

    Is this to be accessible from a public website, if so, that's a spam relay right there.
    I added the shebang but still nothing. I do get an Oracle error though:

    Can't load 'C:\oracle\product\10.1.0\db_2\perl\5.6.1\lib\MSWin32-x86/auto/Socket/Socket.dll' for module Socket: load_file:The specified module could not be found at C:\oracle\product\10.1.0\db_2\perl\5.6.1\lib\MSWin32-x86/XSLoader.pm line 75.
    at C:\oracle\product\10.1.0\db_2\perl\5.6.1\lib\MSWin32-x86/Socket.pm line 451
    Compilation failed in require at C:\oracle\product\10.1.0\db_2\perl\site\5.6.1\lib/Net/SMTP.pm line 13.
    BEGIN failed--compilation aborted at C:\oracle\product\10.1.0\db_2\perl\site\5.6.1\lib/Net/SMTP.pm line 13.
    Compilation failed in require at C:\Inetpub\wwwroot\cgi-bin\mail.pl line 2.
    BEGIN failed--compilation aborted at C:\Inetpub\wwwroot\cgi-bin\mail.pl line 2.
  10. #6
  11. 'fie' on me, allege-dly
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    Location
    in da kitchen ...
    Posts
    12,894
    Rep Power
    6444
    There's nothing apparently related to oracle in the script above, though it seems you've installed perl under the oracle directory, is that what you intended?

    Is that the whole script?
    --Ax
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
    BIT COINS ANYONE
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    103
    Rep Power
    10
    Originally Posted by Axweildr
    There's nothing apparently related to oracle in the script above, though it seems you've installed perl under the oracle directory, is that what you intended?

    Is that the whole script?
    LOL
    No.

    I have no f****** clue as to how Perl and Oracle got mixed up. Looks like I'll have to reinstall. Here's the official script:

    #!/C:/Perl/bin/perl
    use Net::SMTP;
    use CGI qw(:standard);

    my $to = param("to"); #here we retrieve the importan user information
    my $from = param("from");
    my $subject = param("subject");
    my $message = param("message");
    my $mailserve = param("mailserver");

    print header;
    print "<h3>The request has been processed.";
    print "Thank You $from</h3>";

    $smtp = Net::SMTP->new($mailserver); #this creates a new instance of an SMTP server

    #for all of the following lines, we use -> which is Perl's scope operator, it's equivalent to the dot operator in JavaScript
    #or C, C++ and Java
    $smtp->mail($ENV{USER}); #sets the user
    $smtp->mail("$to"); #sets the destination
    $smtp->data(); #this is the clause that the server will actually send real data
    $smtp->datasend("To: $to \n"); #datasend() issues a command to the server. Here we send To: plus the actual value and a newline
    $smtp->datasend("From: $from \n"); #followed by the sender info
    $smtp->datasend("Subject: $subject \n"); #subject
    $smtp->datasend("\n");
    $smtp->datasend("$message \n"); #the message
    $smtp->datasend(); #an empty stub
    $smtp->quit; #and we close the server
  14. #8
  15. 'fie' on me, allege-dly
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    Location
    in da kitchen ...
    Posts
    12,894
    Rep Power
    6444
    $smtp->mail($ENV{USER}); # this line seems to be the bogey

    When you run this from the command line, it returns
    Code:
    Can't call method "mail" on an undefined value at test.pl line 19.
    Content-Type: text/html; charset=ISO-8859-1
    
    <h3>The request has been processed.Thank You </h3>
    Are you sure $ENV{'USER'} has a value on your system, try hardcoding a value for this for the purposes of testing

    HTH
    --Ax
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
    BIT COINS ANYONE
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    103
    Rep Power
    10
    Originally Posted by Axweildr
    $smtp->mail($ENV{USER}); # this line seems to be the bogey

    When you run this from the command line, it returns
    Code:
    Can't call method "mail" on an undefined value at test.pl line 19.
    Content-Type: text/html; charset=ISO-8859-1
    
    <h3>The request has been processed.Thank You </h3>
    Are you sure $ENV{'USER'} has a value on your system, try hardcoding a value for this for the purposes of testing

    HTH
    Here's somethine else. I commented the line in question out and hard coded the user and still nothing. But, when I tried to run it from dos shell I got the following:

    This application has failed to start because Perl56.dll was not found. Re-installing the application may fix this problem.
    I reinstalled it three times now, still nthing.
  18. #10
  19. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Posts
    1,137
    Rep Power
    173
    Originally Posted by Michal Augustyn
    Originally Posted by Axweildr
    it seems you've installed perl under the oracle directory, is that what you intended?
    I have no f****** clue as to how Perl and Oracle got mixed up.
    IIRC, Oracle installs it's own captive perl interpreter under its directory structure. This way Oracle has a version of perl that's been tested and known to work so it doesn't have to rely on the system one which has an unknown (to Oracle) and untested configuration. You may want your own system perl interpreter for your own scripts but removing the one under the Oracle directory may cause some Oracle functions to stop working.
  20. #11
  21. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Posts
    1,137
    Rep Power
    173
    Originally Posted by Axweildr
    $smtp->mail($ENV{USER}); # this line seems to be the bogey

    When you run this from the command line, it returns
    Code:
    Can't call method "mail" on an undefined value at test.pl line 19.
    The bogey is actually the line above it. The "Can't call method ... on an undefined value" error means the object on which the method is called is undefined, $smtp in this case.

    Here are the offending lines. Note that the variable set by the param is $mailserve and the one used to instantiate Net::SMTP is $mailserver. This is type of variable mismatch is one excellent reason you should be using strict.
    Code:
    my $mailserve = param("mailserver");
    $smtp = Net::SMTP->new($mailserver);
    To get a better error, test $smtp with the following and you'll see when $smtp isn't getting instantiated properly:
    Code:
    #!/C:/Perl/bin/perl
    use strict; # turn on strict - a very good thing.
    use Net::SMTP; 
    use CGI qw/:standard/;
    my $mailserver = param('mailserver');
    my $smtp = Net::SMTP->new($mailserver)
        || die "cannot connect to mailserver";
    Last edited by Conundrum; May 7th, 2006 at 05:09 PM.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    103
    Rep Power
    10
    Originally Posted by Conundrum
    The bogey is actually the line above it. The "Can't call method ... on an undefined value" error means the object on which the method is called is undefined, $smtp in this case.

    Here are the offending lines. Note that the variable set by the param is $mailserve and the one used to instantiate Net::SMTP is $mailserver. This is type of variable mismatch is one excellent reason you should be using strict.
    Code:
    my $mailserve = param("mailserver");
    $smtp = Net::SMTP->new($mailserver);
    To get a better error, test $smtp with the following and you'll see when $smtp isn't getting instantiated properly:
    Code:
    #!/C:/Perl/bin/perl
    use strict; # turn on strict - a very good thing.
    use Net::SMTP; 
    use CGI qw/:standard/;
    my $mailserver = param('mailserver');
    my $smtp = Net::SMTP->new($mailserver)
        || die "cannot connect to mailserver";
    I'm glad you told me about that Oracle crap. So now I'm stuck. How can I separate the Oracle perl interpreter (which I barely use and cn efficetively scrap) from the ActiveState perl interpreter . I'd like to have both work independently if possible, but I gather that it's either one or the other in this case.
  24. #13
  25. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Posts
    1,137
    Rep Power
    173
    Originally Posted by Michal Augustyn
    I'm glad you told me about that Oracle crap. So now I'm stuck. How can I separate the Oracle perl interpreter (which I barely use and cn efficetively scrap) from the ActiveState perl interpreter . I'd like to have both work independently if possible, but I gather that it's either one or the other in this case.
    Usually it's enough to specify the path to the perl interpreter in your shebang line. If you're using the CLI, you can also specify the full directory path to the perl interpreter you want so you don't get the first one in your path.
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    103
    Rep Power
    10

    Ok


    Originally Posted by Conundrum
    Usually it's enough to specify the path to the perl interpreter in your shebang line. If you're using the CLI, you can also specify the full directory path to the perl interpreter you want so you don't get the first one in your path.
    That's the thing, I thought I specified the right directory in the shebang, but it still fails with that oracle error. My shebang is:

    Code:
    #!/C:/Perl/bin/perl
    Which basically amounts to
    C:/Perl/bin/perl.exe

    I'm still missing something, I just don't know what yet.
  28. #15
  29. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2004
    Posts
    1,137
    Rep Power
    173
    Type the following and you'll see what @INC directories your perl has been compiled with. @INC is the path perl searches to find modules.
    Code:
    C:\perl\bin\perl -V
    It should end with something like:
    Code:
    Characteristics of this binary (from libperl):
      Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
      Locally applied patches:
            ActivePerl Build 810
            22751 Update to Test.pm 1.25
            21540 Fix backward-compatibility issues in if.pm
      Build under MSWin32
      Compiled at Jun  1 2004 11:52:21
      @INC:
        c:/Perl/lib
        c:/Perl/site/lib
        .
    Last edited by Conundrum; May 7th, 2006 at 09:55 PM.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo