I have this code in several forms, but when I recieve messages from any of them the from/reply address is either blank or some long name that is unrecognizable.
Well clearly you’re not doing something right in your code before it. Also your very first line has $from = ‘$email’; which will not work because the single quotes tell php not to do anything and so $from will literally be ‘$email’ not the value of $email.
<?php
session_start();
require_once('recaptchalib.php');
$errors = array('recaptcha'=>'');
//reCaptcha public & private keys
$publickey = "6LfWgL8SAAAAALli4JmS3bijs_gF7F9JufTg0CVJ";
$privatekey = "GFVWgL8SAAAAAGFevGi3vp-p4lvYyeQ2ToWR8ryf";
/* Subject and Email Variables */
$from = '$email';
$subject = 'Certificate Request';
$to = 'samuel@searchtransparencysem.com';
//samuel@searchtransparencysem.com
//aaa@aaa.com
/* Gathering Data Variables */
if(isset($_POST['quote_form'])){
$flag = true;
$resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field']);
if (!$resp->is_valid) {
$errors['recaptcha'] = $resp->error;
$flag = false;
}
// Does everything the greyed out part does. Also sets cookies for elements.
foreach($_POST as $key=>$value){
if(is_array($_POST[$key])){
if($key = "insurance_lines"){
foreach($value as $index=>$name){
$$name = $name;
setcookie($name, $$name);
}
$$key = implode(", ", $value);
}else{
setcookie($key, $$key);
$$key = implode(", ", $value);
}
}else{
if($key == "recaptcha_challenge_field" || $key == "recaptcha_response_field"){ continue;}
$$key = $value;
//echo "<strong>".$key."</strong> ".$$key."<br />";
setcookie($key, $$key);
}
}
if($flag == true) {
$body =<<<BODY
<br><hr><br>
<h2>Request a Certificate</h2>
Name of Insured: $name_of_insured <br>
Name of Person Requesting the Certificate: $person_requesting_certificate <br>
Telephone: $telephone <br>
Email Address: $email_address <br>
Fax: $fax <br>
Name of Certificate Holder: $name_of_certificate_holder <br>
Mailing Address: $mailing_address <br>
Mailing City: $mailing_city <br>
Mailing State: $mailing_state <br>
Mailing Zip: $mailing_zip <br>
Requiring to be named as an additional insured: $additional_insured <br>
Relationship of Certificate Holder to the Insured: $relationship <br>
Lines of Business to be included: $insurance_lines <br>
Please note anything you would like us to know while quoting your account: $things_to_know <br>
How did you hear about us?: $referral_source <br>
Explain Other or give the name of the person that referred you: $referral_source_explain <br>
BODY;
$headers = "Content-type: text/html\\r\
";
$headers .= "From: $email\\r\
";
$headers .= "Reply-To: $email\\r\
";
$headers .= "Return-Path: $email\\r\
";
$send = mail($to,$subject,$body,$headers);
header('Location: sent.html');
exit;
}
}
?>
Right, WHERE are you setting $email? - I don’t see anything like $email = $_POST[‘email’]; anywhere.
Secondly as I’ve mentioned above, $from = ‘$email’ will only set $from to ‘$email’. By that I mean if you
print $from;
your html will literally display $email NOT the value of it.
Please don’t dump and run. I’ve made the point above in my last post you need to fix it before just dumping your code on us to fix and then running before even fixing this basic fault.
Sorry about the “dump and run”. I’ve been overloaded with other projects recently and am just getting back to this one now. I have fixed this problem on my own. I appreciate everyone’s input.