PHP mail()函数没有网络的主机上运行 [英] PHP mail() function does not work on web-host

查看:174
本文介绍了PHP mail()函数没有网络的主机上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在发送使用PHP mail()函数的电子邮件的问题。我知道PHP脚本我的作品,因为我有它的另一网络托管公司相同的副本,它在那里工作。

我觉得它与网络托管公司本身。做任何你知道我需要什么,以使其发挥作用呢?有什么我需要告诉他们安装?我想他们是在Apache上运行。

谢谢,
阿米特

有关澄清的目的,这里是邮件的脚本。

 < PHP$为='my@email.com';
$主题='从你的网站联系;$消息=
下面是从联系表格的详细信息。 \\ n \\ n。
'名称: ' 。 $ _REQUEST ['名']。 \\ n \\ n。
'电话号码: ' 。 $ _REQUEST ['电话'。 \\ n \\ n。
'电子邮件地址: ' 。 $ _REQUEST [电子邮件。 \\ n \\ n。
'注释: ' 。 $ _REQUEST ['意见'];$电子邮件= $ _REQUEST [电子邮件];
$标题=发件人:。 $电子邮件。 \\ r \\ n。
            '回复: ' 。 $电子邮件。 \\ r \\ n。
          X梅勒:PHP /'。 phpversion();
$标题=MIME-版本:1.0。 \\ r \\ n;
$头=内容类型:text / plain的;字符集= ISO-8859-1;//垃圾邮件检查
$海峡= $ _REQUEST ['垃圾邮件'];
$ STRE = $ _REQUEST [电子邮件];如果($海峡!=10|| $ STRE ==)
{
    回声< D​​IV ALIGN =中心的风格=颜色:红色'>一个或多个表单字段是不正确的,你会在3秒内被重定向到联系页面< / DIV方式>,
?>< META HTTP-当量=刷新内容=3; URL = HTTP://engineercreativity.com/samples/biz/contact>< - 编辑此 - >!< PHP
}其他{
    电子邮件($到,$主题,$消息,$头);
?>
< META HTTP-当量=刷新内容=0; URL = HTTP://engineercreativity.com/thankyou.html> <! - EDIT这个问题,以及 - >
<! -
< D​​IV CLASS =文本ALIGN =中心的风格=文本对齐:中心;颜色:绿色;>
< BR />
感谢您与我们联系!
< BR />
已成功发送的消息!
< / DIV>
- >
< PHP
}
?>


解决方案

如果它是一个专用的服务器,请确保你已经安装Postfix邮件(http://www.postfix.org/)

我今天遇到这个错误本身作为SMTP服务器不可用(我以为它,因为在默认情况下,但不是)

I'm having issues sending emails using the php mail() function. I know the php script I have works because I have an identical copy of it on another web-hosting company and it works there.

I think it has to do with the web-hosting company itself. Do any of you know what I need to do in order to make it work? Is there something I need to tell them to install? I think they're running on Apache.

Thanks, Amit

For clarification purposes, here is the mail-script.

<?php

$to = 'my@email.com';
$subject = 'Contact from your website';

$message = 
'Below are details from the Contact Us Form ' . "\n\n" . 
'Name: ' . $_REQUEST['name'] . "\n\n" . 
'Telephone Number: ' . $_REQUEST['phone'] . "\n\n" . 
'E-mail address: ' . $_REQUEST['email'] . "\n\n" . 
'Comments: ' . $_REQUEST['comments'];

$email = $_REQUEST['email'];
$headers = 'From: ' . $email . "\r\n" .
            'Reply-To: ' . $email . "\r\n" .
          'X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1";       

//SPAM CHECK
$str = $_REQUEST['spam'];
$strE = $_REQUEST['email'];

if( $str != "10" || $strE == "")
{
    echo "<div align='center' style='color:red'>One or more of the form fields were incorrect, you will be redirected to the contact page within 3 seconds.</div>";
?><meta http-equiv="refresh" content="3;URL=http://engineercreativity.com/samples/biz/contact"><!-- EDIT THIS -->

<?php   
} else {
    mail ($to, $subject, $message, $headers);
?>
<meta http-equiv="refresh" content="0;URL=http://engineercreativity.com/thankyou.html"> <!-- EDIT THIS AS WELL -->
<!--
<div class="text" align="center" style="text-align: center; color: green;">
<br/>
Thank you for contacting us!
<br/>
The message was succesfully sent!
</div>
-->
<?php
} 
?> 

解决方案

If it is a dedicated server, make sure you have postFix Mail installed (http://www.postfix.org/)

I faced this error today itself as the SMTP server was not available (i assumed it as there by default, but not)

这篇关于PHP mail()函数没有网络的主机上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆