0
我想在php中創建郵件表單。我編寫了ny form的html代碼。我在同一個文件中寫入html表單和php代碼。所以我不想使用另一個文件發送電子郵件。發送郵件在php中發送郵件文件
<div class="agent-contact">
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><strong>Contact Form </strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td>
<form name="form1" method="post" action="">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="16%">Subject</td>
<td width="2%">:</td>
<td width="82%"><input name="subject" type="text" id="subject" size="50"></td>
</tr>
<tr>
<td>Detail</td>
<td>:</td>
<td><textarea name="detail" cols="50" rows="4" id="detail"></textarea></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="customer_mail" type="text" id="customer_mail" size="50"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="Submit" value="Send Message"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
我的PHP代碼
<?php
$subject ="$subject";
$message="$detail";
$mail_from="$customer_mail";
$header="from: $name <$mail_from>";
$to ='[email protected]';
$send_contact=mail($to,$subject,$message,$header);
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROffR";
}
?>
提交發送消息按鈕時,我如何發送郵件?我有相同的文件。
使用類PHPMailer的http://phpmailer.worxware.com/ – 2013-02-27 11:31:07
也可以參考[PHP:使用窗體處理](http://php.net/manual/en/tutorial .forms.php) – 2013-02-27 11:31:58
從長遠來看,使用PHP郵件庫如[Zend_Mail](http://framework.zend.com/manual/2.1/en/modules/zend.mail.introduction的.html) – djskinner 2013-02-27 11:32:55