PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Johnm
Forum Contributor
Posts: 344 Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:
Post
by Johnm » Tue Dec 03, 2002 2:53 pm
When using this:
Code: Select all
<?php
$cmd="mail -s 'Model Number Request' ".$h_email." < ".$msg;
exec($cmd);
?>
The browser hangs for about 60 seconds then loads the page.
The exec() command is with out a doubt the problem.
PHP 4.2.3
Apache 1.3.27
any Ideas anyone?
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Tue Dec 03, 2002 4:26 pm
maybe you should try
Code: Select all
$cmd="mail -s 'Model Number Request' ".$h_email." < echo '$msg'";otherwise the shell tries to open files with names like the content of $msg
Johnm
Forum Contributor
Posts: 344 Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:
Post
by Johnm » Wed Dec 04, 2002 7:07 am
From that angle it is important to see the rest of the code.
Code: Select all
<?php
if(strcmp($h_email,""))
{
$msg="/custom/net/web/model_number/".time();
$fd=fopen($msg,"w");
while (list($key, $val) = each($HTTP_POST_VARS))
{
$type=substr($key,0,2);
if(!strcmp($type,"s_"))
{
$name=substr($key,2,strlen($key));
if(strlen($val) < 45)
$data="".$name.": ".$val."\n";
else
$data="".$name.":\n".$val."\n";
fwrite($fd,$data,strlen($data));
}
}
$data="</body></html>";
fwrite($fd,$data,strlen($data));
fclose($fd);
$cmd="Mail -s "Model Number Request" ".$h_email." < ".$msg;
exec($cmd);
unlink($msg);
}
?>
Where $msg is actualy a file name.
Any ideas?
John M
Johnm
Forum Contributor
Posts: 344 Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:
Post
by Johnm » Wed Dec 04, 2002 2:18 pm
Okay, it gets worse.... I can run mail and send mail from the command line with no problem (Linux Advanced Server 2.1 with Piranha for failover)
I tried using exec() shell_exec() passthru() and everything else in the book to no avail. Nothing happens. The page eventually loads but no mail is sent. So I tried using the PHP mail() function... same thing...
It is almost like there is no communication between the system and PHP.
Any Ideas now?
John M
gyardleydn
Forum Commoner
Posts: 27 Joined: Tue Dec 03, 2002 8:27 am
Post
by gyardleydn » Wed Dec 04, 2002 3:04 pm
I'm no expert but here is a couple of things that might help you or others help you.
Print $cmd and use the output array argument in the exec function to display the results of the mail command. Aftwards post the output here.
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Wed Dec 04, 2002 5:28 pm
and check what happens if you copy the printed $cmd and paste it in the commandline if the error output sounds silly