Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mail script from web server, changing the reply header

Status
Not open for further replies.

dreamaz

Technical User
Dec 18, 2002
184
0
0
CA
hello,

I have a mail script on a hosted web server which clients can fill out and send to me, problem is that when i get the mail, it shows From: <my webserver account> instead of the sender's email address so when i reply im replying it to myself or have to cut and paste the clients' email addy instead. Hope this makes sense, this is what im running:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ME</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251">
<link href="main.css" rel="stylesheet" type="text/css">
</head>

<body>
<table border="0" cellpadding="0" cellspacing="0" width="547">
	<tr>
		<td>
			<table border="0" cellpadding="0" cellspacing="0" width="356" height="165">
				<tr>
					<td height="57" align="left" valign="top" background="images/3_26.gif" width="279">
						<img src="images/3_12.gif" height="57">
					</td>
				</tr>
				<tr>
					<td height="108" background="images/3_26.gif"> 
						<span class="title">
						<center>
							Contact ME
						</center>
						</span>
					</td>
				</tr>
			</table>
		</td>
		<td>
			<table border="0" cellpadding="0" cellspacing="0" width="*" height="165">
				<tr>
					<td>
						<img src="images/3_13.jpg" width="191" height="165">
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="547" background="images/3_26.gif">
	<tr>
		<td width="15">&nbsp;
			
		</td>
      <td width="513"> 
			<p class="main"> 
  <br>
		  <strong>Location:</strong> ME is located at Home.  Please contact us via e-mail, phone or MSN. 
              <br>
              <br>
        </p>
		  <span class="main">
<table align="center">
  <tr>
    <td class="title"> 
      <strong>Mon - Fri:</strong> 5pm - 10pm
      </td>
		  <td class="title"> 
		    <strong>Sat - Sun:</strong> 2pm - 10pm
	      </td>
	  </tr>
</table>
<br>
<br>
<span class="main">Please e-mail or call to arrange an
<br>
</span><br>
<table cellpadding="0" cellspacing="0">
  <tr>
    <td class="main"> 
      <strong>Phone #:</strong> &nbsp; &nbsp;
      </td>
		  <td class="main"> 
		    
	      </td>
	  </tr>
  <tr>
    <td class="main"> 
      <strong>MSN:</strong>  &nbsp; &nbsp;
      </td>
		  <td class="main"> 
		    Not@now.net
	      </td>
	  </tr>
  <tr>
    <td class="main"> 
      <strong>Email:</strong>  &nbsp; &nbsp;
      </td>
		  <td class="main"> 
		    <a href="gu@ME.ca">gurvir@ME.ca</a>
	      </td>
	  </tr>
</table>
<br>
<?
/* YOU MUST EDIT THIS LINE */
$youremail = "myhotmail@address.com";
?>

<? error_reporting(1); ?>
<? 

# stupid user check

if($youremail == "user@domain") {
print "You have to change one variable (email address) in this file.</body></html>"; exit;
}

?>

<?
if(($message) || ($name) || ($email) || ($subject)) {

if($name) { } else {
print "Your message was not sent because you didn't specify your name.<br>\n";
}

if($email) { } else {
print "Your message was not sent because you didn't specify your email.<br>\n";
}


if($subject) { } else {
print "Your message was not sent because you didn't specify a subject.<br>\n";
}


if($message) { } else {
print "Your message was not sent because you didn't write anything in the 'message' field.<br>\n";
}

print "<br>";

if(($message) && ($name) && ($email) && ($subject)) {

print "Your email was sent successfully.<br><br>\n";

$to = $youremail;
$from = $email;

$VIRTUAL_REMOTE_HOST = gethostbyaddr( $REMOTE_ADDR );

if( $REMOTE_HOST ) { } else {
$REMOTE_HOST = "NULL";
}

if( $VIRTUAL_REMOTE_HOST ) { } else {
$VIRTUAL_REMOTE_HOST = "NULL";
}


mail ($to, $subject, "A message from $name at $email:\r\n $message \r\n\r\n$name's remote host is $REMOTE_HOST and $name's specified hostname is $VIRTUAL_REMOTE_HOST. \r\nThe sender's IP Address is $REMOTE_ADDR and the sender's \r\nUser-Agent string is $HTTP_USER_AGENT." ) or print "An unknown error occured.<br>";

$name = NULL;
$email = NULL;
$subject = NULL;
$message = NULL;

}

}
?>
<table>
  <form method=POST action="<? echo $PHP_SELF; ?>">
<tr><td class="main">Name:</td><td><input type="text" name="name" value="<? echo $name; ?>" size=30></td></tr>
<tr><td class="main">Email:</td><td><input type="text" name="email" value="<? echo $email; ?>" size=30></td></tr>
<tr><td class="main">Subject:</td><td><input type="text" name="subject" value="<? echo $subject; ?>" size=30></td></tr>
<tr><td valign="top" class="main">Message:</td><td>
<textarea cols=27 rows=8 name="message"><? echo $message; ?></textarea>
</td></tr>
<tr><td></td><td><input type="Submit" value="Send">
</form></table></td>
	</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0"width="547">
	<tr>
		<td>
			<img src="images\3_30.gif">
		</td>
	</tr>
</table>
</body>
</html>



Any help is appreciated.

Thanks,

dR
 
Hi

Did you read the PHP documentation of the [tt]mail()[/tt] function ? It has example for solving your request.
Code:
mail ($to, $subject, "A message from $name at $email:\r\n $message \r\n\r\n$name's remote host is $REMOTE_HOST and $name's specified hostname is $VIRTUAL_REMOTE_HOST. \r\nThe sender's IP Address is $REMOTE_ADDR and the sender's \r\nUser-Agent string is $HTTP_USER_AGENT."[red], "Reply-To: $email\r\n"[/red] ) or print "An unknown error occured.<br>";

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top