Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP scripts work on Windows server but not Linux

Status
Not open for further replies.

brogan

Technical User
Oct 7, 2003
44
0
0
GB
Hi guys,

I have an enquiry form on my website that works fine on a Windows server but not on a Linux server (nothing enters my email box?).

Here's the code below (apologies TGML isn't used - the submit button wasn't visible when I went to preview), any help would be greatly appreciated!!!

Thanks,

Mark
Code:
<?php

ini_set("sendmail_from", "root@mywebsite.co.uk"); 

if(isset($_POST['submit_x'])){


// get posted data into local variables
if(isset($_POST['Title'])){$Title = $_POST['Title'];}
if(isset($_POST['Name'])){$Name = $_POST['Name'];}
$tmp = $_POST['AddressofPropertytobeSold'];
if (strlen($tmp)>0)
 $AddressofPropertytobeSold = $tmp;
else
 $AddressofPropertytobeSold ="--";
$tmp=$_POST['PostCode'];
if (strlen($tmp)>0)
 $PostCode =$tmp;
else
 $PostCode ="--";
if(isset($_POST['TypeofProperty'])){$TypeofProperty = 
$_POST['TypeofProperty'];}
if(isset($_POST['time'])){$besttime = 
$_POST['time'];}

if(isset($_POST['NumberofBedrooms'])){$NumberofBedrooms = 
$_POST['NumberofBedrooms'];}
if(isset($_POST['ReasonforSelling'])){$ReasonforSelling = 
$_POST['ReasonforSelling'];}
$tmp=$_POST['HowWouldyouPreferustoContactYou'];
if (strlen($tmp)>0)
 $HowWouldyouPreferustoContactYou =$tmp;
else
 $HowWouldyouPreferustoContactYou ="--";
$tmp=$_POST['EstimatedValueoftheProperty'];
if (strlen($tmp)>0)
 $EstimatedValueoftheProperty =$tmp;
else
 $EstimatedValueoftheProperty ="--";
if(isset($_POST['hear'])){$hear = $_POST['hear'];}
if(isset($_POST['email'])){$email = $_POST['email'];}
if(isset($_POST['addme'])){$addme = $_POST['addme'];}

//code for mail, preparing msgtext for mail
$subject = "Website Enquiry";
$msgtext="<html><head><title>Enquiry from
 mywebsite.co.uk</title><style 
TYPE=text/css>body{font-family:arial;    font-size:3px;}</style> 
</head><body><table border=0 cellspacing=2 cellpadding=2 
width=70%><tr><td colspan=2 ><br><br>Lead 
Details<BR> </td></tr><tr><td colspan='2' height='1' 
bgcolor='#1F8992'></td></tr>";
if ($Title == "Other"){
 $msgtext .= "<tr><td width=36%><B>Title</B></td><td>". $Title . 
"</td></tr><tr><td width=36%><B>Name</B></td><td>". $Name .
 "</td></tr>";
}
else{
 $msgtext.="<tr><td width=36%><B>Name</B></td><td>". $Title . " " . 
$Name . "</td></tr>";
}
$msgtext.="<tr><td><B>Address of Property to be 
Sold</B></td><td>".$AddressofPropertytobeSold."</td></tr><tr><td><B>Post 
Code</B></td><td>".$PostCode."</td></tr><tr><td><B>Type of 
Property</B></td><td>".$TypeofProperty."</td></tr><tr><td><B>Number of 
Bedrooms</B></td><td>".$NumberofBedrooms."</td></tr><tr><td><B>Reason 
for 
Selling</B></td><td>".$ReasonforSelling."</td></tr><tr><td><B>Telephone 
number 
</B></td><td>".$HowWouldyouPreferustoContactYou."</td></tr><tr><td><B>Email</B></td><td>".$email."</td></tr><tr><td><B>Realistic 
value of the 
property</B></td><td>".$EstimatedValueoftheProperty."</td></tr>
<tr><td><B>How did you hear about us</B></td>
<td>".$hear."</td>
</tr>
<tr><td><B>Best time to call </B></td>
<td>".$besttime."</td>
</tr>
<tr><td
 colspan='2' 
height='1' bgcolor='#1F8992'></td></tr><tr><td colspan=2> <TR><TD 
colspan=2>    </table></body></html>";
$to        = "info@mywebsite.co.uk";
$from    = $email; //"enquiries@mywebsite.co.uk";
$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$body = $msgtext;

@mail($to, $subject, $body, $header, "-f".$_REQUEST[email]);
}
?>
 
First thing I'd do is take the @ off the mail() command and see if you get an error reported. You might need to look at php.ini to enable errors to be displayed as well
 
absolutely agree with ingresman.

mail is completely different from linux to windows. linux mail sends the file off to sendmail or some other mta for handling. whereas on windows the command needs to connect to an smtp server that is going to accept relay requests from the webserver.
 
Hi guys,

Firstly, many thanks for your replies!

I have tried removing the @ sign and it makes no difference. I get no error message and nothing arrives in my inbox?

Any other ideas?

Regards,

Mark
 
you need to make sure that your php.ini file identifies the right smtp server. and that the smtp server will accept relay requests from your web server. remember to reboot after each edit to the php.ini (or at least rester the web server)
 
Can you send email from the linux server by using semdmail from the command line.
 
oops, i had it the wrong way round.

as igresman infers, if php is not throwing an error then the mail command is working fine. that means it is delivering your mail to the mta (sendmail).

i'll bet that sendmail is either not started up or there is an internal configuration issue within sendmail. check you sendmail logs for more information and perform the test that ingresman suggests.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top