好的,所以我正在做我的第一个 php 表单,我尝试过用谷歌搜索,但没有任何运气(如果有人知道任何关于基本 php 或 php 表单的好教程,我已经看过很多它们并且可以使用一个好的)。
无论如何,基本上我无法弄清楚为什么我的电子邮件是通过 Hotmail 中的 ( Unknown ) 发送的,即使当我去回复时,我收到了正确的电子邮件。
这是HTML页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First Basic Form</title>
</head>
<style type="text/css">
</style>
<!-- Form Opening Tage -->
<table width="600">
<tr><td>
<form method="post" name="form1" action="http://www.richie.id.au/TAFE/form /php/form1_send.php"><br /><br />
<table width="600" border="5" bordercolor="#990000">
<!-- Name Field -->
<tr><td>Name:</td></tr>
<tr><td><input type="text" name="name" size="40" /></td></tr>
<!-- email Field -->
<tr><td>Email:<br /></td></tr>
<tr><td><input type="text" name="email" size="40" /><br /><br /></td></tr>
<!-- Message Field -->
<tr><td>Message: <br /></td></tr>
<tr><td><textarea name="message" width="100%" rows="12" cols="60" style="resize:none;"> </textarea><br /><br /></td></tr>
<!-- Sbumit Button -->
<tr><td><input type="submit" name="submit" /><br /><br /></td></tr>
</table>
</form>
</td>
</tr>
</table>
<body>
</body>
</html>
这是PHP页面
<?PHP
// $name variable declared as name that was inputed into text field
$name = $_POST['name'];
// $email variable declared as email that was inputed into text field
$visitor_email = $_POST['email'];
// Email to show the message as coming from
$email_from = $_POST["$visitor_email"];
// Message text asigned to variable message
$message = $_POST['message'];
// Email subject
$subject = 'New form submission from richie.id.au';
// Email Body
$email_body = "New message from: $name.\n\n Message:\n\n $message\n";
// Email address to send form submission email to
$to = "richie_hayward_01@hotmail.com";
// headers
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
// Function that actually sends the mail
mail($to,$subject,$email_body,$headers);
?>