1. 程式人生 > >PHP練習4 表單郵件(mail函式)

PHP練習4 表單郵件(mail函式)

 1.表單郵件 feedback.html

<html>
<head><title>Bob's Auto Parts - Customer Feedback</title></head>
<body>

<h1>Customer Feedback</h1>
<p>Please tell us what you think.</p>

<form action="processfeedback.php" method="post">

<p>Your name:<br/>
<input type="text" name="name" size="40" /></p>
     
<p>Your email address:<br/>
<input type="text" name="email" size="40" /></p>
     
<p>Your feedback:<br/>
<textarea name="feedback" rows="8" cols="40" wrap="virtual" /></textarea></p>
     
<p><input type="submit" value="Send feedback" /></p>

</form>


</body>
</html>

2. processfeedback.php

   <?php
  date_default_timezone_set("PRC");
  $name=trim($_POST['name']);
  $email=trim($_POST['email']);
  $feedback=trim($_POST['feedback']);
  $toaddress="[email protected]";//此處是你要送達人的郵件地址
  $emailcontent="customer name:".$name."feedback:".$feedback;
  $subject="Feedback from wed site";
  $fromaddress="From:
[email protected]
";//發件人即自己的郵件地址,隨便寫一個即可 mail($toaddress,$subject,$emailcontent,$fromaddress);//第一個引數是收件人地址,第二個是標題,第三個是內容,第四個是發件人地址 ?> <html xmlns="http://www.w3.org/1999/html"> <head> <title>Bob's Auto Parts-Feedback Submitted</title> </head> <body> <h1>Feed Back Submitted</h1> <p>Your Feed back have been sent.</p> <?php echo nl2br($emailcontent); ?> </body> </html>

3.登入squirrelmail 檢視user1郵件