2013-10-01 54 views
0

上我试图在共享服务器上发送邮件。我的错误页面是PHP邮件()SMTP服务器响应:452 4.3.1出内存的Windows服务器

<br /> 
<b>Warning</b>: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response: 452 4.3.1 Out of memory in <b>D:\hshome\......\form.php</b> on line <b>21</b><br /> 
email didnt send 
<META HTTP-EQUIV ="Refresh" CONTENT =" 1; URL= Thank.html" /> 

这是form.php的

<?php 
include ("config.php"); 
$mail_check=true; 
if(trim($_POST["name"])=="") 
    $mail_check=false; 
if(trim($_POST["email"])=="") 
    $mail_check=false; 
if(trim($_POST["subject"])=="") 
    $mail_check=false; 

if($mail_check){ 
    $to=$config["email"]; 
    $subject = $_POST["subject"]; 
    $message = '<html><head><title>$lang["newemailarriveed"]</title></head><body> 
    test 
    </body></html>'; 
    $headers = 'MIME-Version: 1.0' . "\r\n"; 
    $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; 
    $headers .= 'From: '.$_POST["name"].' <'.$_POST["email"].'>' . "\r\n"; 

    if(mail($to, $subject, $message, $headers)){ 
     echo $lang["success"]; 
    } 
    else{ 
     echo $lang["eror1"]; 
    } 
}else{ 
    echo $lang["eror2"]; 
} 
?> 

config.php

<?php 
// ServCombina 
// Contact Form By TalGarty 
    $config = Array( 
     "email" => "[email protected]", 
     );   

    $lang = Array( 
     "newemailarriveed" => "new mail", 
     "newemailfrom" => "from", 
     "info" => "detail", 
     "fullname" => "name", 
     "iemail" => "email", 
     "phone" => "phone", 
     "success" => "success", 
     "eror1" => "email didnt send", 
     "eror2" => "one or more of the fields are empty", 
     );   
?> 

*这是Windows共享服务器

我不得不说,我不知道太多的PHP,我试图通过asp.net发送电子邮件,它的工作,但我不能移动到asp.net米我必须留在php

asp.net下面的代码工作:

String s_name = "", s_email = "", s_phone = ""; 
if (name != null && name.Text != null) { s_name = name.Text; }  
if (email != null && email.Text != null) { s_email = email.Text; } 
if (phone != null && phone.Text != null) { s_phone = phone.Text; } 

MailMessage mailMessage = new MailMessage(); 
mailMessage.To.Add("[email protected]"); 
mailMessage.From = new MailAddress("[email protected]"); 
mailMessage.Subject = "test"; 
mailMessage.Body = @"<!DOCTYPE html> "+ 
        "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><title>new email</title></head><body> " + 
        "test" + 
        "</body></html>"; 
SmtpClient smtpClient = new SmtpClient("mail.example.com"); 
smtpClient.Send(mailMessage); 
Response.Redirect("~/aaa/Thank.html"); 

回答

1

解决方案:

添加在文件的顶部此行:

ini_set('SMTP','mail.example.com'); 
    ini_set('sendmail_from','[email protected]'); 

ini_set('memory_limit','32M');没有帮助所以我没有把它放在文件

+0

您的服务器是Windows? –

+0

在你的问题中指定你的服务器类型。谢谢。 –

+0

是的,它是Windows,我编辑了我的问题。 – Nir

0

只要编辑你的php.ini,并切换到任何你所需要的memory_limit的。例如。 memory_limit的= 32M

  • 您需要访问修改php.ini中的系统上。这种变化是全球性的,将被系统上运行的所有php脚本使用。一旦您更改此值,您将需要重新启动Web服务器才能使其处于活动状态。 请记住,此限制有其逻辑,并不会人为增加它,因为写得不好的PHP脚本可能会在没有适当限制的情况下过度杀死系统。 注意:如果您知道自己在做什么并想要移除内存限制,则可以将此值设置为-1。

  • memory_limit的使用的.htaccess单个文件夹/虚拟主机 改变全球memory_limit的可能不是一个好主意,你可能会更好地改变这种只有一个文件夹(通常是一个应用程序或虚拟主机)内改变需要这种值的功能发生了变化。要做到这一点,你必须添加到相应位置的.htaccess类似:php_value memory_limit的64M

编辑

如果你的服务器是共享的,有增加至允许的内存量的方式PHP正好在你的脚本中。在你的文件的顶部放置下面的代码。

ini_set('memory_limit','32M'); 

上述代码将PHP可用的最大内存量增加到32 MB。同样,该设置仅针对正在运行的脚本进行调整。

+0

我存储在共享服务器上的网站,只需创建一个'php.ini'文件并将其存储在网站根目录中? – Nir

+0

查看更新的答案。将该代码包含在实际执行mail()函数的文件的顶部。该设置仅针对该执行周期进行调整。 –

+0

我把这行放在'include(“config.php”);'(也在该行下面尝试)并且仍然出现'内存不足'。 – Nir