<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title></title>
</head>
<body>
<form action="mail.php" method="post">
<table>
<tr>
<td>Mail to:</td>
<td><input type="text" name="mail_to" /></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject" /></td>
</tr>
<tr>
<td>Mail From:</td>
<td><input type="text" name="mail_from" /></td>
</tr>
<tr>
<td colspan="2"><textarea name="contents" cols="50" rows="10"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Send Mail"/></td>
</tr>
</table>
</form>
<?php
$mailTo = $_POST["mail_to"];
$mailFrom = $_POST["mail_from"];
$subject = $_POST["subject"];
$contents = $_POST["contents"];
if ($mailTo && $mailFrom && $subject && $contents) {
// 前面那些HTML代码都是为了填写信息更容易,实际发送邮件代码只是下面一句
// 但首先机器上得启动邮件发送程序,Mac下是默认启动的,Linux好像要自己先配置启动
mail($mailTo, $subject, $contents, "From:".$mailFrom);
echo "Mail is successfully sent!", "<br>";
}
?>
</body>
</html>