PHP 电子邮件在 WIMP 上失败
我有一个 WordPress 网站,其中的联系表单在我的 MAMP 环境中运行良好,但是当我发布到我的客户端 WIMP 服务器时,我遇到了失败。
- 我对 WIMP 环境一点也不熟悉——如何检查 PHP 错误日志
- 顺便问一下,WIMP 上的 PHP 电子邮件发送问题是否会导致这种情况?
代码:
<?php
if ($_POST["contact_name"]<>'') {
$ToEmail = '[email protected]';
$EmailSubject = 'New contact message';
$mailheader = "From: ".$_POST["contact_email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["contact_email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "<b>Name:</b> ".$_POST["contact_name"]."<br>";
$MESSAGE_BODY .= "<b>Email:</b> ".$_POST["contact_email"]."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
<h4>Your message was sent. We will be in touch with you shortly.</h4>
<?php
} else {
<form id="contact-form" name="contact" method="post" action="#">
<label for="contact-name">Name *</label>
<input type="text" id="contact-name" name="contact_name" tabindex="1" class="required"/>
<label for="contact-email">Email</label>
<input type="text" id="contact-email" name="contact_email" tabindex="2" class="email" />
<input type="submit" id="contact-submit" name="contact_submit" value="" tabindex="8" />
</form>
<?php
};
?>
I've got a WordPress site with a contact form that works fine on my MAMP environment, but when I publish to my clients WIMP server I get a failure.
- I am not at all familiar with WIMP environments- how does one go about checking PHP error logs
- Offhand, are there issues with PHP emailing on WIMP that would be causing this?
Code:
<?php
if ($_POST["contact_name"]<>'') {
$ToEmail = '[email protected]';
$EmailSubject = 'New contact message';
$mailheader = "From: ".$_POST["contact_email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["contact_email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "<b>Name:</b> ".$_POST["contact_name"]."<br>";
$MESSAGE_BODY .= "<b>Email:</b> ".$_POST["contact_email"]."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure");
?>
<h4>Your message was sent. We will be in touch with you shortly.</h4>
<?php
} else {
<form id="contact-form" name="contact" method="post" action="#">
<label for="contact-name">Name *</label>
<input type="text" id="contact-name" name="contact_name" tabindex="1" class="required"/>
<label for="contact-email">Email</label>
<input type="text" id="contact-email" name="contact_email" tabindex="2" class="email" />
<input type="submit" id="contact-submit" name="contact_submit" value="" tabindex="8" />
</form>
<?php
};
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Windows 没有像 UNIX 类型操作系统那样内置电子邮件服务器。您需要配置 php.ini 以添加用于中继电子邮件的 SMTP 服务器信息。
Windows does not have a built in email server like unix type OSs tend to have. You need to configure php.ini to add SMTP server information through which to relay email.
`mail()' 函数的 PHP 手册页 详细介绍了许多Windows 特定点。然而,可能影响您的要点在本节中:(引用)
还有其他一些事情需要考虑;请阅读手册页了解更多信息。
希望有帮助。
The PHP manual page for the `mail()' function details a number of Windows-specific points. However, the main points which could affect you are in this section: (to quote)
There are a few other things to consider as well; please read the manual page for more.
Hope that helps.