PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > comp.info.servers.unix > Weird Apache/Sendmail problem
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.info.servers.unix Web servers for UNIX platforms.

Weird Apache/Sendmail problem

Réponse
 
LinkBack Outils de la discussion
Vieux 30/08/2006, 19h19   #1
Matt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Weird Apache/Sendmail problem

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

  Réponse avec citation
Vieux 31/08/2006, 09h53   #2
Max Dittrich
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Weird Apache/Sendmail problem

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

  Réponse avec citation
Vieux 31/08/2006, 12h20   #3
Matt
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Weird Apache/Sendmail problem


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


  Réponse avec citation
Vieux 31/08/2006, 23h38   #4
Max Dittrich
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Weird Apache/Sendmail problem

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
  Réponse avec citation
Vieux 02/09/2006, 19h42   #5
Juha Laiho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Weird Apache/Sendmail problem

"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)
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 23h08.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10568 seconds with 13 queries