Jump to content

[SOLVED] Email prob - From not displaying email


Zombies

Recommended Posts

Hi

 

I have a website with a contact owner form, when sent and recieved the email doesnt contain the senders email but the email addrees of the site admin (me!)

 

I've tried a few things which just leaves the from blank which I prefer for now.

 

any ideas?

 

Code for entering infol -

echo "<p>";
echo "<a name='contact'></a>";
echo "<form action='mailme.php' method='post' target='_blank'>";
echo "<table class='detailTable' cellspacing=0 border=0 width='90%'>";
echo "<tr>";
echo "<td class='subHeader' colspan=2>Reply to Ad</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='30%'><strong>Contact</strong></td><td>".$member['FName']. " " .$member['LName']."</td>";
echo "</tr><tr>";
echo "<td>Your Email</td><td><input type='text' name='from' validate='email' required='yes' message='Enter Email Address.'></td>";
echo "</tr><tr>";
echo "<td>Subject</td><td><input type='text' name='subject' size='40' validate='text' required='yes' message='Enter Subject.'></td>";
echo "</tr><tr>";
echo "<td>Message</td><td><textarea style='width:100%;height:70px' name='message' >"; 
echo "Please contact me regarding the following ad: $adurl";
echo "</textarea></td>";
echo "</tr><tr>";
echo "<td> </td><td><input type='submit' onClick='validate(this.form); return document.formSubmit;' value='Send'></td>";
echo "</tr>";
echo "</table>";
echo "<input type='hidden' name='to' value='".$member['Email']."'>";
echo "<input type='hidden' name='oktosend' value='yes'>";
echo "</form>";
echo "</p>";

 

Code for sending the mail -

 

$node = new sqlNode();
	$node->table = 'admin';
	$node->select = "*";
	$node->where = "where ID = 1";

	$result = $mysql->select($node) or die($mysql->debugPrint());
	if(mysql_num_rows($result)<1){
		die("Invalid site settings");
	}
	$settings = mysql_fetch_assoc($result);
	$message = "Reply To: ".$_POST['from']."\n".$_POST['message'];
	$sent = mail($_POST['to'],$_POST['subject'],$message,'FROM: '.$settings['Email']);
	if($sent){
		echo "<script>alert('Message Sent');window.close();</script>";

Hi

 

I have a website with a contact owner form, when sent and recieved the email doesnt contain the senders email but the email addrees of the site admin (me!)

 

I've tried a few things which just leaves the from blank which I prefer for now.

 

any ideas?

.......

Code for sending the mail -

 

$node = new sqlNode();
	$node->table = 'admin';
	$node->select = "*";
	$node->where = "where ID = 1";

	$result = $mysql->select($node) or die($mysql->debugPrint());
	if(mysql_num_rows($result)<1){
		die("Invalid site settings");
	}
	$settings = mysql_fetch_assoc($result);
	$message = "Reply To: ".$_POST['from']."\n".$_POST['message'];
	$sent = mail($_POST['to'],$_POST['subject'],$message,'FROM: '.$settings['Email']);
	if($sent){
		echo "<script>alert('Message Sent');window.close();</script>";

 

According to $sent, you are mailing to user who filled out the form with subject posted from a form a message from ID=1's email address from database in table admin.

 

From the PHP Manual:

 

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

 

So, your headers (including who the message is from, i.e. the member's email address) would come at the end, and your email would come in the front if you wanted to receive a message from a member to your email with their email address showing as the from so you could reply to it (or what have you).  That appears to be what you are trying to do.

 

If you want the message to be from the user sending you the message, I believe you would need to switch $settings['Email'] and $_POST['to'].

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.