用PHP实现用From发送电子邮件

说明:用PHP实现发送电子邮件是比较简单的,大家可以看看如下完整代码。

1,把下面这段代码复制到你的网页中,可以复制到.HTML文件中。

  1. <form action="mail.php" method="post">
  2. <p align="center">
  3. <font >
  4. Name:<br>
  5. <input type="text" name="name" ><br>
  6. E-Mail Address:<br>
  7. <input type="text" name="email" ><Br>
  8. Website URL:<br>
  9. <input type="text" name="url" ><Br>
  10. <input type="submit" value="Submit" >

2,建立mail.php文件,并且和上面的保存在同一个目录中。

  1. <?
  2. $contactemail = "you@yourdomain.com";
  3. $subject = "You choose";
  4. $message .= "Name: $namen";
  5. $message .= "E-mail: $emailn";
  6. $message .= "Website URL: $urln";
  7. mail($contactemail, $subject, $message);
  8. echo "Thanks for mailing me, I should reply with in a few
  9. days."
  10. ?>