Jump to content

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      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\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'].

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.