Sender email not displaying in email inbox

I cannot get the email address of the sender to display in the inbox, only in the body.

$name = '';
$phone = '';
$email = '';
$comments = '';
if(isset($_POST['subm'])) {
$error = array();
$data = array();
include "../datafunction.php";

/*Please modify variable values according to requirement*/
$min = 3;   //Min length of string
$max = 10;   // Max length of string
$maxc = 300;   // Max length of string
$receiverEmail = '';   //Set Email Receiver Email address
$receiverName = 'Mike';   //Set Email Receiver name
$FromEmail ='email';  //Set From Email
$FromName = 'name';  //Set From name
$mailSubject = 'Mail for Me';  //Set Email subject

foreach($_POST as $key=>$val)
		if(validBlank($val) == 1)
			$error[] = "Name cannot blank";
		$checkLength = validStrLen($val,$min,$max);
			if($checkLength == 'short') {
				$error[] = "Name is too short, minimum is ".$min." characters (".$min.", ".$max.")";
			} else {
				$error[] = "Name is too long, maximum is ".$max." characters (".$min.", ".$max.")";
		$name = fnSanitizeStringr($val);
		if(validBlank($val) == 1)
			$error[] = "Phone number cannot blank";
		$validation = new PhoneValidation();
		$isvalidPhone = $validation->validate('phone',$val);
		if($isvalidPhone != 1)
			$error[] = 'Phone number is not in valid US Format';
		$phone = $val;
		if(validBlank($val) == 1)
			$error[] = "Email address cannot blank";
		$val = fnSanitizeEmaill($val);
		$test = new EmailValdation;
		$test->email = $val;
		if($test->checkEmailDomain() == 0) { //Check DNS of Email Address
			$error[] = 'Invalid email address';
		$email = $val;
		if(validBlank($val) == 1)
			$error[] = "Comments cannot blank";
		echo $checkLength = validStrLen($val,$min,$maxc);
			if($checkLength == 'short') {
				$error[] = "Comments field is too short, minimum is ".$min." characters (".$min.", ".$max.")";
			} else {
				$error[] = "Comments field is too long, maximum is ".$maxc." characters (".$min.", ".$max.")";
		$comments = fnSanitizeStringr($val);
	$data[$key] = _clean($val);
if(count($error) > 0)
	echo '<div class="error"><ul>';
	foreach($error as $er)
		echo '<li>'.$er.'</li>';
	echo '</ul></div>';
else {
$msg = "<table><tr><td>Name:</td><td>".$data['name']."</td></tr>
	require '../mailer/PHPMailerAutoload.php';
	//Create a new PHPMailer instance
	$mail = new PHPMailer();
	// Set PHPMailer to use the sendmail transport
	//Set who the message is to be sent from
	//Set who the message is to be sent to
	//Set the subject line
	$mail->Subject = $mailSubject;
	//Read an HTML message body from an external file, convert referenced images to embedded,
	//convert HTML into a basic plain-text alternative body
	//send the message, check for errors
	if (!$mail->send()) {
		echo "Mailer Error: " . $mail->ErrorInfo;
	} else {
		header("Location: thank-you.html");

} ?>

I believe it is an error in the FromEmail . I have changed that to $email and still no change

Where is $FromEmail coming from - is it just set in your code, or is it something the user fills in as part of your form? When you receive the email, what is in the ‘from’ address?

I had paid someone to make the form and now he wants to nickel and dime me for some.

in the html, here is the email area.

<div class="fieldgroup">
                <label for="email">Email</label>
                <input type="text" name="email" value="<?php echo $email; ?>">

I don’t know why he changed it in the php code.

What I get in my email inbox is:

Root User - as opposed to the person’s real name from input field like you get in yahoo or gmail
user@localhost - as opposed to the person’s email

but in the message body, it shows the senders email,phone, name, etc.

So let me see if I have this - you display a form on your site, user fills in their email address and some other bits of information, and that is all put in an email and sent to you? And the problem is that the “from” address in the email you receive is not the users email address, it’s a fixed value?

If I’m reading that correctly, I would imagine you’ll have all sorts of trouble sending an email with a “from” address that isn’t yours. You’d have to use an email server that can accept an email with any from-address, which I would think is a bit of a security hole on the mail server as it would allow mass untraceable emails, and maybe fall foul of other peoples SPF records (if anyone still uses them). If it’s your own mail server that might not be so bad if you have security in place to make sure that no-one else can use it as a mail relay.

What you could do is set the “reply to” address, so that even though it’s come from your generic email address, clicking reply would go to the original sender. Not all mail clients support it though.

where in my code would I put that?

Just before the SetFrom() function:

$mail->AddReplyTo(email, name);

Have a read up on the phpmailer docs, there is some talk that you have to set this before you set the From-address or it will not work correctly. I haven’t used it, I’m just googling this stuff as a learning aid.

Appreciate the help but unfortunately, that did not work.

I am not a php coder by any means. I just wanted a form that I could use and move back to designing.

I looked at the phpmailer docs and now feel I was ripped off by some freelancer at Odesk and then I tried another on 5r…both failed in what I wanted to which I thought was simple. He knew good & well I wanted a mailer similar to what I had that was secure and he picked a free open-source script and inserted my requested features. the from field displaying in your email box is pretty standard.
I reviewed the mailers docs but the phpmailer docs asks you to set the from email address but it should be different each time.