CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
using SMTP methods...

 



icemann
Deleted

May 4, 2000, 6:57 AM

Post #1 of 5 (682 views)
using SMTP methods... Can't Post

I'm having difficulty getting any of the SMTP methods to work. I used the standard const. with no options, but any line after returns syntax error. I've even tried coping known good code, but get the same result. I included the library for SMTP. Anyone have an idea why this occurs?



Jasmine
Administrator / Moderator

May 4, 2000, 8:22 AM

Post #2 of 5 (682 views)
Re: using SMTP methods... [In reply to] Can't Post

Could you please post your exact error, and the portion of the code using the methods?


icemann
Deleted

May 4, 2000, 8:43 AM

Post #3 of 5 (682 views)
Re: using SMTP methods... [In reply to] Can't Post

Well, I'm able to get around the syntax errors using a different approach I found in another posting on this site, but now it seems that the SMTP object can't find its constructor method, even though I can see it in the library. I just picked up Perl, so this could very easily be something simple. Also, our WebSite is hosted on an NT machine, which might cause some compatibilty issues with the Compiler/Interpretor. Thanks for the help.

***SCRIPT CODE***
use Net::SMTP;
#require "cgi-lib.pl";

#The strings below which refer to corporate #URLs were replaced for the purpose of #posting.

$smtp_server="mymailserver.com";
$domain_name="mydomain.com";

@to=$input{'to'};
$from=$input{'from'};
$subject=$input{'subject'};
$body=$input{'body'};

$smtp=Net::SMTP->new($smtp_server,
Hello=>$domain_name,
Timeout=>30,
Debut=>1,
);

$smtp->mail($from);
$smtp->to('$to');
$smtp->data();
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("$body\n");
$smtp->dataend();

$smtp->quit;

print qq~
TO: $to
FROM: $from
SUBJECT: $subject

$body
~;
exit;

***RESULTS USING IE 5.0***
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


Can't locate object method "new" via package "Net::SMTP" at D:\test_sites\test


icemann
Deleted

May 4, 2000, 8:48 AM

Post #4 of 5 (682 views)
Re: using SMTP methods... [In reply to] Can't Post

Also, I caught the "debut" typo in the constructor call, and changed it to debug, but get the exact same message.


Peter Van Hoecke
Deleted

May 5, 2000, 3:13 AM

Post #5 of 5 (682 views)
Re: using SMTP methods... [In reply to] Can't Post

probeably a stupid remark, but the new constructor returns undef if it failed, so you can do "if( $smtp = Net::SMTP->new...)" to cath problems with the mailserver and so.
Every other method of Net::SMTP returns 0/1, so you can | | it. I had a lot of problems with SMTP, and by putting | | print "saomething" after it, I could chase the problem down.

Good hunting

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives