|
|
|
|
||||||
| comp.info.servers.unix Web servers for UNIX platforms. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I have a simple few lines of Perl I'm trying to run from a cgi program
to send some email. My code looks like: use Net::SMTP; my $email="mda\@x.com"; my $msg="hello tst\n"; $smtp = Net::SMTP->new('smtp.x.com');# or die "Unable to open the connection"; $smtp->mail('me@yahoo.com'); $smtp->to($email); $smtp->data($msg); $smtp->dataend(); $smtp->quit; When I run the code via command line it works. When I run it via a cgi program from a webpage I get: Can't call method "mail" on an undefined value Everything I"ve searched for says it is because my script cannot contact the smtp server, but that's not the case because when I run it via the command line, it works fine. It looks like it has to be some permisssion thing, either in sendmail or apache. Any thoughts? Thanks |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Am 30 Aug 2006 11:19:27 -0700 schrieb Matt:
> I have a simple few lines of Perl I'm trying to run from a cgi program > to send some email. > [...] > > It looks like it has to be some permisssion thing, either in sendmail > or apache. > > Any thoughts? - Running Apache in a chroot without proper resolver-config (DNS) - try IP-address - SELinx controls the service - Firewall-rules denying outgoing connections for the CGI-User .... ..max |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Max Dittrich wrote: > Am 30 Aug 2006 11:19:27 -0700 schrieb Matt: > > > I have a simple few lines of Perl I'm trying to run from a cgi program > > to send some email. > > > [...] > > > > It looks like it has to be some permisssion thing, either in sendmail > > or apache. > > > > Any thoughts? > > - Running Apache in a chroot without proper resolver-config (DNS) - try > IP-address > - SELinx controls the service > - Firewall-rules denying outgoing connections for the CGI-User > > ... Using the ip address does not work. The firewall rules have been disabled and still doesn't work. The same block of code works from a standalone perl program. It just doesn't work when executed via cgi. > > .max |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Hi Matt,
>>> Any thoughts? >> >> - Running Apache in a chroot without proper resolver-config (DNS) - try >> IP-address X >> - SELinx controls the service What operating system are you running and what Distribution, if you're running Linux? I'm not very deep into these SELinux things - just enough to disable it. But I read a few man pages and found that there is a policy which disallows any outgoing connections (Fedora Core 5). If you're running any release of Fedora, try this: # selinuxenabled && getsebool httpd_can_network_connect >> - Firewall-rules denying outgoing connections for the CGI-User X > Using the ip address does not work. > The firewall rules have been disabled and still doesn't work. > The same block of code works from a standalone perl program. It just > doesn't work when executed via cgi. At the end I would start to add some debugging (print STDERR) to Net:SMTP. :/ ..max |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
"Matt" <mda@unb.ca> said:
>I have a simple few lines of Perl I'm trying to run from a cgi program >to send some email. > >My code looks like: >use Net::SMTP; >my $email="mda\@x.com"; >my $msg="hello tst\n"; > $smtp = Net::SMTP->new('smtp.x.com');# or die "Unable to open the connection"; > $smtp->mail('me@yahoo.com'); .... >When I run the code via command line it works. When I run it via a cgi >program from a webpage I get: >Can't call method "mail" on an undefined value NOTE: The "or die ..." in the above is commented out. Do you get that error message (in any logs) if you enable that piece of code? You might also try printing out value of "$!" as part of the error message; that might have additional clues as to what went wrong. -- Wolf a.k.a. Juha Laiho Espoo, Finland (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++ "...cancel my subscription to the resurrection!" (Jim Morrison) |
|
![]() |
| Outils de la discussion | |
|
|