php 邮件表单无法正常工作
我正在尝试让邮件表单正常工作,这是我正在使用的代码..
<table class="mail" table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><strong>Contact Form </strong></td>
</tr>
</table>
<table class="mail" table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="send_contact.php">
<table class="mail" 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>Message</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"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
这是运行的脚本..
<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";
// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";
// Enter your email address
$to ="email";
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "thanks for sending us a message!"
if($send_contact){
Print "<html>";
Print "<head>";
Print "<link href='styles.css' rel='stylesheet' type='text/css' />";
Print "</head>";
Print "<body>";
Print "<img src=images/banner2.png alt='banner' />";
Print "<p>Thanks for sending us a message!, please wait while you are being redirected to the homepage</p>";
Print "</body>";
Print "</html>";
}
else {
Print "<html>";
Print "<head>";
Print "<link href='styles.css' rel='stylesheet' type='text/css' />";
Print "</head>";
Print "<body>";
Print "<img src=images/banner2.png alt='banner' />";
echo "ERROR";
Print "</body>";
Print "</html>";
}
?>
当我将电子邮件放入“电子邮件”时,当它发送时,我只收到来自@localhost的消息,我知道邮箱正在工作,因为我使用了不同的脚本,但我想使用这个脚本,因为我可以更改字体和大小。
谢谢
I'm trying to get a mailform working, this is the code im using..
<table class="mail" table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><strong>Contact Form </strong></td>
</tr>
</table>
<table class="mail" table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="send_contact.php">
<table class="mail" 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>Message</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"> <input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
this is the script that runs..
<?php
// Contact subject
$subject ="$subject";
// Details
$message="$detail";
// Mail of sender
$mail_from="$customer_mail";
// From
$header="from: $name <$mail_from>";
// Enter your email address
$to ="email";
$send_contact=mail($to,$subject,$message,$header);
// Check, if message sent to your email
// display message "thanks for sending us a message!"
if($send_contact){
Print "<html>";
Print "<head>";
Print "<link href='styles.css' rel='stylesheet' type='text/css' />";
Print "</head>";
Print "<body>";
Print "<img src=images/banner2.png alt='banner' />";
Print "<p>Thanks for sending us a message!, please wait while you are being redirected to the homepage</p>";
Print "</body>";
Print "</html>";
}
else {
Print "<html>";
Print "<head>";
Print "<link href='styles.css' rel='stylesheet' type='text/css' />";
Print "</head>";
Print "<body>";
Print "<img src=images/banner2.png alt='banner' />";
echo "ERROR";
Print "</body>";
Print "</html>";
}
?>
when I put my email in 'email' when it sends I just get a message from @localhost, I know the mailbox is working as I used a different script, but I would like to use this script as I can change font and size.
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您正在尝试使用
register_globals
,但它已被禁用(这是一件好事)。您需要使用
$_POS
T 从表单中获取数据。It looks like you're trying to use
register_globals
, but it's disabled (which is a good thing).You need to get the data from the form using
$_POS
T instead.尝试使用
mail()
的附加-f
参数来指定 sendmail 程序的发件人地址。Try using the additional
-f
parameter tomail()
in order to specify the From address to the sendmail program.