0

Can anyone think of a logical reason to why a contact form which works perfectly well on my 123 reg account, will not work on my clients account? when I test it on my side, I get the email and the form contents through to my inbox perfectly but when the same codes are used on my clients account, with his email address, he receives an email with no data..

<?php

$EmailFrom = "webmaster@pb.co.uk";
$EmailTo = "loans@website.co.uk";
$Subject = "Testing";
$Name = Trim(stripslashes($_POST['Name'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "eMail: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom");

// redirect to success page 
if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=http://website/thankyou.html\">";
}
else{
    print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>
Amber Sabre
  • 143
  • 9
  • Does the client even have a properly configured mail server? – patricksweeney Dec 11 '13 at 13:49
  • Hi, yes. according to the 123 support team. thats about as much help they were.. he does recieve the email but with no data from which has been inputted into the form.. – Amber Sabre Dec 11 '13 at 13:53
  • I suggest you to change .= with simple . I'ts easier `$Body = "Name: ".$Name."\n";` than `$Body .= "Name: "; $Body .= $Name; $Body .= "\n";` and avoid using uppercase letters in your variable names... – artur99 Dec 11 '13 at 13:55
  • Hi, does this look right to you? // prepare email body text $Body = ""; $Body = "name: ".$name."\n"; $Body = "name: ".$email."\n"; $Body = "name: ".$message."\n"; – Amber Sabre Dec 11 '13 at 14:07

2 Answers2

0

change

"From: $EmailFrom"

to

"From: $EmailFrom" . "\r\n" 
zzlalani
  • 22,960
  • 16
  • 44
  • 73
  • 1
    Hi there, are you able to tell me what this means? I have only just got my head around the basic script provided by my host – Amber Sabre Dec 11 '13 at 13:54
  • focus this line `$success = mail($EmailTo, $Subject, $Body, "From: $EmailFrom");` and reread my answer. – zzlalani Dec 11 '13 at 13:56
0

Add header.

$Body  = 'MIME-Version: 1.0' . "\r\n";
$Body .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$Body .= 'From: '. $EmailFrom . "\r\n" . 'X-Mailer: PHP/' . phpversion();
user2486495
  • 1,709
  • 11
  • 19