0

我正在尝试在共享服务器上发送邮件。我的错误页面是

 <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" => "info@example.com", 
        );         

    $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("example@example.com");
mailMessage.From = new MailAddress("info@example.com");
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");
4

2 回答 2

1

解决方案:

在文件顶部添加以下行:

   ini_set('SMTP','mail.example.com');
   ini_set('sendmail_from','info@example.com');

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

于 2013-10-01T11:20:11.377 回答
0

只需编辑您的 php.ini 并将 memory_limit 更改为您需要的任何内容。例如。memory_limit = 32M

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

  • 使用 .htaccess 为单个文件夹/虚拟主机更改 memory_limit 更改全局 memory_limit 可能不是一个好主意,您最好只在一个文件夹(通常是一个应用程序或虚拟主机)内更改它,该文件夹需要更改其功能。为此,您必须添加到相应的位置 .htaccess 类似: php_value memory_limit 64M

编辑

如果您的服务器是共享的,有一种方法可以在您的脚本中增加 PHP 允许的内存量。在您的文件顶部放置以下代码。

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

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

于 2013-10-01T10:18:31.620 回答