질문&답변
클라우드/리눅스에 관한 질문과 답변을 주고 받는 곳입니다.
리눅스 분류

netmania 웹메일 에러 문의합니다..

작성자 정보

  • 궁금 작성
  • 작성일

컨텐츠 정보

본문

이것때문에 며칠째 고생합니다...

메일을 보내기 하면 메일은 보내지지만, 다음과 같은 에러가 발생하네요..

Warning: fread(): supplied argument is not a valid stream resource in /usr/local/netmania/htdocs/bin/send.php on line 646

Warning: fread(): supplied argument is not a valid stream resource in /usr/local/netmania/htdocs/bin/send.php on line 646

Warning: fread(): supplied argument is not a valid stream resource in /usr/local/netmania/htdocs/bin/send.php on line 646

Warning: Cannot modify header information - headers already sent by (output started at /usr/local/netmania/htdocs/bin/send.php:646) in /usr/local/netmania/htdocs/bin/send.php on line 746

제가 php를 몰라서 어케 수정해야할지도 모르겠구여...

send.php 부분도 올립니다...아랫 부분에 line 646 부분 체크 하겠읍니다...

도움 부탁드립니다...

 

<?php
...

...
/* 
 DEBUG Code Value 
 0 : work silent
 1 : work + sendmail msg
 2 : work + sendmail msg + message body
           */

/* debug code */

$debug=0;

if ($debug)
 header("Content-type: text/plain");


/* include section */

include ("../lib/u-check.lib");
include ("../lib/database.lib");
include ("../lib/template.lib");
include ("../lib/decode.lib");

/* email address null check */
if(!$receiver)
{
 mm_error("$MSG_NO_RECEIVER_MAIL",winclose);
}

/* database connect */
$dbh = dbconnect();


$sql_select = "select pf_name, pf_remail, pf_signature from profile".
 " where pf_uid='$UID'";
$sth = dbquery($dbh,$sql_select);

list($name,$remail,$signature) = dbselect($sth);

/* Personal signature add systerm signature */
$signature = " ".$signature.$MAIL_BASE_SIGNATURE;


$to_email_cnt = 0;
$cc_email_cnt = 0;

$to_email_temp = split("<|>|,",$receiver);

for ($i=0;$i<=sizeof($to_email_temp);$i++)
{
 if (strstr($to_email_temp[$i],'@'))
 {
  $to_email[$to_email_cnt++]=$to_email_temp[$i];
 }
}

$cc_email_temp = split("<|>|,",$cc);

for ($i=0;$i<=sizeof($cc_email_temp);$i++)
{
 if (strstr($cc_email_temp[$i],'@'))
 {
  $cc_email[$cc_email_cnt++]=$cc_email_temp[$i];
 }
}

/* set default value */
$save=1;

if (strstr($cmd,"$MSG_DELETE"))
 $save=0;
if ($charset_send == "_autodetect")
 $charset_send = $CHARSET;
 


/* check file attach */

$check_attach = 0;

if ($attach_1 != "none") $check_attach=1;
if ($attach_2 != "none") $check_attach=1;
if ($attach_3 != "none") $check_attach=1;
if ($org_mailname != "") $check_attach=1;


/*  mail level check  */
switch ($LEVEL)
{
 case 5:
  $level_db='L';
  $LEVEL="X-Priority: $LEVEL X-MSMail-Priority: Low ";
  break;
 
 case 1:
  $level_db='H';
  $LEVEL="X-Priority: $LEVEL X-MSMail-Priority: High ";
  break;
 
 default:
  $level_db='M';
  $LEVEL="X-Priority: $LEVEL X-MSMail-Priority: Normal ";
  break;
}


/* Make Unique Boundary value */
$time_micro = microtime();
$time_micro = str_replace(" ","",$time_micro);
$boundary="$time_micro"."_NanjangPart_Tel_82_2_542_9296_";


switch ($send_type)
{

    case "html":
   //if ($signature_chk == 1)
  //{
   $message_body = $content." ".str_replace(" ","<BR> ",$signature)." ";
  //}
  //else
  //{
  // $message_body = $content;
  //}

  $ContentType = "Content-Type: text/html; charset=$charset_send ";
  $message_body_stand=$message_body;
  $message_body_stand=str_replace("\'","'",$message_body_stand);
  $message_body_stand=str_replace(chr(92).chr(34),chr(34),$message_body_stand);
  $message_body_stand=str_replace(chr(92).chr(92).chr(34),chr(34),$message_body_stand);
  $kind = 1;
  break;
   
    default:

        //if ($signature_chk == 1)
  //{
   $message_body = $content." ".$signature." ";
  //}
  //else
  //{
  // $message_body = $content;
  //}
        
  $ContentType = "Content-Type: text/plain; charset=$charset_send ";
  $message_body_stand=$message_body;
  $message_body_stand=str_replace("\'","'",$message_body_stand);
     $message_body_stand=str_replace(chr(92).chr(34),chr(34),$message_body_stand);
     $message_body_stand=str_replace(chr(92).chr(92).chr(34),chr(34),$message_body_stand);
     $kind = 1;
     break;
}


/* make file name or directory  */

if ($save)
{
 /* Make masseageID */
 $msg_id = microtime().'.'.$UID.'@'.$MAIL_SERVER_NAME;
 $msg_id = str_replace(" ","",$msg_id);

 list($year,$mon,$day,$hour) = split(" ",strftime("%Y %m %d %H"));

 $day=(int)$day;
 $mon=(int)$mon;
 $hour=(int)$hour;

 if (!is_dir("$MAIL_DATA/$year"))
  mkdir ("$MAIL_DATA/$year/",0750);

 if (!is_dir("$MAIL_DATA/$year/$mon"))
  mkdir ("$MAIL_DATA/$year/$mon/",0750);

 if (!is_dir("$MAIL_DATA/$year/$mon/$day"))
  mkdir ("$MAIL_DATA/$year/$mon/$day/",0750);

 if (!is_dir("$MAIL_DATA/$year/$mon/$day/$hour"))
  mkdir ("$MAIL_DATA/$year/$mon/$day/$hour/",0750);

 $filename = "$MAIL_DATA/$year/$mon/$day/$hour/$msg_id";
 $filename_eml = $filename.".eml";
 $wp = fopen($filename_eml,"w");
}

/* hello to sendmail (open 25port) */
  
$fp = fsockopen("127.0.0.1",25,&$errno, &$errstr, 30);

if(!$fp)
{
   mm_error("$errstr ($errno)",winclose);
}

set_socket_blocking($fp,1);
$smtp_msg = fgets($fp,255);

if ($debug)
 echo $smtp_msg;

if (substr($smtp_msg,0,1)=='5')
 mm_error($smtp_msg);

fputs($fp,"HELO www.netmania.org ");
$smtp_msg = fgets($fp,255);

if ($debug)
 echo $smtp_msg;

if (substr($smtp_msg,0,1)=='5')
 mm_error($smtp_msg);

fputs($fp,"MAIL from: $UID@$MAIL_SERVER_NAME ");
$smtp_msg = fgets($fp,255);

if ($debug)
 echo $smtp_msg;

if (substr($smtp_msg,0,1)=='5')
 mm_error($smtp_msg);

for ($i=0; $i < $to_email_cnt; $i++)
{
 fputs($fp,"RCPT to: $to_email[$i] ");
 $smtp_msg = fgets($fp,255);

 if ($debug)
  echo $smtp_msg;

 if (substr($smtp_msg,0,1)=='5');
}

for ($i=0; $i < $cc_email_cnt; $i++)
{
 fputs($fp,"RCPT to: $cc_email[$i] ");
 $smtp_msg = fgets($fp,255);

 if ($debug)
  echo $smtp_msg;

 if (substr($smtp_msg,0,1)=='5');
}

fputs($fp,"DATA ");
$smtp_msg = fgets($fp,255);

if ($debug)
 echo $smtp_msg;

if (substr($smtp_msg,0,1)=='5')
 mm_error("$smtp_msg",winclose);

 


/* make mail header  */
switch ($send_bit)
{
 case 7:

  fputs($fp,"From: $from ");

  if ($save)
   fputs($wp,"From: $from ");

  if ($debug==2)
   echo ("From: $from ");
  break;
  
  
 default:
  fputs($fp,"From: $from ");

  if ($save)
   fputs($wp,"From: $from ");

  if ($debug==2)
   echo ("From: $from ");
  break;
}


if ($remail != "")

 fputs($fp,"Return-Path: $remail ");

 if ($save)
  fputs($wp,"Return-Path: $remail ");
 
 if ($debug==2)
  echo ("Return-Path: $remail ");
}

fputs($fp,"To: $receiver ");

if ($save)
 fputs($wp,"To: $receiver ");

if ($debug==2)
 echo ("To: $receiver ");

if ($cc)
{
 fputs($fp,"Cc: $cc ");
 
 if ($save)
  fputs($wp,"Cc: $cc ");
 
 if ($debug==2)
  echo ("Cc: $cc ");
}

switch ($send_bit)
{
 case 7:
  fputs($fp,"Subject: =?$charset_send?B?".base64_encode($subject)."?="." ");
 
  if ($save)
   fputs($wp,"Subject: =?$charset_send?B?".base64_encode($subject)."?="." ");
 
  if ($debug==2)
   echo ("Subject: =?$charset_send?B?".base64_encode($subject)."?="." ");
  break;
  
 default:
  fputs($fp,"Subject: $subject ");
 
  if ($save)
   fputs($wp,"Subject: $subject ");
 
  if ($debug==2)
   echo ("Subject: $subject ");
  break;
}

fputs($fp,"X-Originating-IP:  [$REMOTE_ADDR] ");

if ($save)
 fputs($wp,"X-Originating-IP:  [$REMOTE_ADDR] ");

if ($debug==2)
 echo ("X-Originating-IP:  [$REMOTE_ADDR] ");


fputs($fp,"$LEVEL");

if ($save)
 fputs($wp,"$LEVEL");

if ($debug==2)
 echo ("$LEVEL");


fputs($fp,"X-mailer:  netmania mail [ver $MAIL_VERSION] http://www.netmania.org/ ");

if ($save)
 fputs($wp,"X-mailer:  netmania mail [ver $MAIL_VERSION] http://www.netmania.org/ ");

if ($debug==2)
 echo ("X-mailer:  netmania mail [ver $MAIL_VERSION] http://www.netmania.org/ ");

 

if ($check_attach)
{
/* multipart/mixed Mail */

 fputs($fp,"Content-Type: multipart/mixed; ");

 if ($save)
  fputs($wp,"Content-Type: multipart/mixed; ");

 if ($debug==2)
  echo ("Content-Type: multipart/mixed; ");
  
 fputs($fp," boundary="----=$boundary" ");

 if ($save)
  fputs($wp," boundary="----=$boundary" ");

 if ($debug==2)
  echo (" boundary="----=$boundary" ");
}
else
{
/* Normal Mail */

 fputs($fp,"$ContentType");

 if ($save)
  fputs($wp,"$ContentType");

 if ($debug==2)
  echo ("$ContentType");
 

 /* Mail Body Encoding */

 if($send_bit == 7)
 {
  fputs($fp,"Content-Transfer-Encoding: base64 ");
  if ($save) fputs($wp,"Content-Transfer-Encoding: base64 ");
  if ($debug==2) echo ("Content-Transfer-Encoding: base64 ");
  

  /* Mail body 7bit Encoding (by base64) */
  $message_body_stand_temp =base64_encode($message_body_stand);
  $message_body_length = strlen($message_body_stand_temp);
  $i=0;
  $message_body_stand="";
  while($i<$message_body_length)
  {
   $temp = substr($message_body_stand_temp,$i,57);
   $message_body_stand .=$temp." ";
   $i=$i+ 57;
  }
 }
 else
 {
  fputs($fp,"Content-Transfer-Encoding: 8bit ");
  if ($save) fputs($wp,"Content-Transfer-Encoding: 8bit ");
  if ($debug==2) echo ("Content-Transfer-Encoding: 8bit ");

 }
  
 
 fputs($fp," ");

 if ($save)
  fputs($wp," ");

 if ($debug==2)
  echo (" ");
}

fputs($fp," ");

if ($save)
 fputs($wp," ");

if ($debug==2)
 echo (" ");
/* mail head end */

 

if ($check_attach)
{
 fputs($fp,"This is a multi-part message in MIME format. ");
 if ($save)
  fputs($wp,"This is a multi-part message in MIME format. ");
 if ($debug==2)
  echo ("This is a multi-part message in MIME format. ");

 fputs($fp," ");
 if ($save)
  fputs($wp," ");
 if ($debug==2)
  echo (" ");
  
 fputs($fp,"------=$boundary ");
 if ($save)
  fputs($wp,"------=$boundary ");
 if ($debug==2)
  echo ("------=$boundary ");
  
 fputs($fp,"$ContentType");
 if ($save)
  fputs($wp,"$ContentType");
 if ($debug==2)
  echo ("$ContentType");

 if($send_bit == 7)
 {
  fputs($fp,"Content-Transfer-Encoding: base64 ");
  if ($save) fputs($wp,"Content-Transfer-Encoding: base64 ");
  if ($debug==2) echo ("Conte nt-Transfer-Encoding: base64 "); 
 }
 
 fputs($fp," ");
 if ($save)
  fputs($wp," ");
 if ($debug==2)
  echo (" ");    
}
fputs($fp,$message_body_stand);

if ($save)
 fputs($wp,$message_body_stand);

if ($debug==2)
 echo ($message_body_stand);         
fputs($fp," ");

if ($save)
 fputs($wp," ");

if ($debug==2)
 echo (" ");    

 

/* make mail forward attach (mime)  */

if($org_mailname)
{
 $MP = new MailParser;
 $MP->Init($org_mailname);
 $Bound = $MP->Header->Boundary;
  
 for ($i=0;$i<$org_attach_cnt;$i++)
 {
  $temp_var='';
  $temp_var="org_attach_$i";

  if ($$temp_var)
  {

   if ($save) fputs($wp," ");

   fputs($fp," ");

   if ($save) fputs($wp,"------=$boundary ");

   fputs($fp,"------=$boundary ");
   
   $fp2 = fopen($org_mailname,"r");
   $ns1 = $MP->BodyOffset[$i];
   $ns2 = $MP->BodyOffset[$i+1];
                   
   fseek($fp2, $ns1);
   $exit=1;

   while($exit)
   {
    $line = fgets($fp2,255);
    $ns1 = $ns1 + strlen($line);

    if (!stristr($line,$Bound))
    {
     fputs($fp,$line);

     if ($save) fputs($wp,$line);

     if ($debug==2) echo ("$line"); 
    }

    if (($ns1 == $ns2) || ($ns1 > $ns2))
    {
     $exit=0;
    }
   }
  }
 }  
 fclose($fp2);

 
 
/* make mail attach file */
$MAX_ATTACH=3;

for ($att=1; $att <= $MAX_ATTACH; $att++)
{

 if (${"attach_".$att} != "none")
 {
 
  fputs($fp,"------=$boundary ");

  if ($save)
   fputs($wp,"------=$boundary ");

  if ($debug==2)
   echo ("------=$boundary ");
  
  fputs($fp,"Content-Type: ".${"attach_".$att."_type"}."; ");

  if ($save)
   fputs($wp,"Content-Type: ".${"attach_".$att."_type"}."; ");

  if ($debug==2)
   echo ("Content-Type: ".${"attach_".$att."_type"}."; ");
  
  
  fputs($fp," name="=?$charset_send?B?".base64_encode(${"attach_".$att."_name"})."?="."" ");

  if ($save)
   fputs($wp," name="=?$charset_send?B?".base64_encode(${"attach_".$att."_name"})."?="."" ");

  if ($debug==2)
   echo (" name="=?$charset_send?B?".base64_encode(${"attach_".$att."_name"})."?="."" ");
  
  fputs($fp,"Content-Transfer-Encoding: base64 ");

  if ($save)
   fputs($wp,"Content-Transfer-Encoding: base64 ");

  if ($debug==2)
   echo ("Content-Transfer-Encoding: base64 ");
  
  fputs($fp,"Content-Disposition: attachment; ");

  if ($save)
   fputs($wp,"Content-Disposition: attachment; ");

  if ($debug==2)
   echo ("Content-Disposition: attachment; ");
  
  fputs($fp," filename="=?$charset_send?B?".base64_encode(${"attach_".$att."_name"})."?="."" ");

  if ($save)
   fputs($wp," filename="=?$charset_send?B?".base64_encode(${"attach_".$att."_name"})."?="."" ");

  if ($debug==2)
   echo (" filename="=?$charset_send?B?".base64_encode(${"attach_".$att."_name"})."?="."" ");
  
  fputs($fp," ");

  if ($save)
   fputs($wp," ");

  if ($debug==2)
   echo (" ");
  
  $fp2=fopen(${"attach_".$att},"r");

  while($temp=fread($fp2,57))  <----------------------------------------------- line 646
  {
   fputs($fp,base64_encode($temp)." ");

   if ($save)
    fputs($wp,base64_encode($temp)." ");

   if ($debug==2)
    echo (base64_encode($temp)." ");
  }
 }
}

/* close message  */
if ($check_attach)
{
 fputs($fp," ");

 if ($save)
  fputs($wp," ");

 if ($debug==2)
  echo (" ");   
 
 fputs($fp,"------=$boundary"."-- ");

 if ($save)
  fputs($wp,"------=$boundary"."-- ");

 if ($debug==2)
  echo ("------=$boundary"."-- ");
}

if ($save)
 fclose($wp);
 

fputs($fp," . ");
$smtp_msg = fgets($fp,255);

if ($debug) echo $smtp_msg;

fputs($fp,"QUIT ");
$smtp_msg = fgets($fp,255);

if ($debug) echo $smtp_msg;

/* Sendmail (25 Port) close */
fclose($fp);


if ($debug>0)
 print " Save Status = $save ";


if ($save)
{
 if ($debug>0)
  print " SQL ";

 $size     = $CONTENT_LENGTH;
 $datestr  = date('Y/m/d H:i:s', time());
 $UID      = dbquote($UID);
 $receiver = dbquote($receiver);
 $remail   = dbquote($remail);
 $subject  = dbquote($subject);
 $from  = dbquote($from);
 $mb_attach = 'N';

 if ($check_attach) $mb_attach = 'Y';

 $sql_insert = "insert into mailbox (mb_uid, mb_msgid, mb_from, mb_to, mb_reply,    ".
        "mb_subject, mb_date, mb_folder, mb_check, mb_attach, mb_filename,   ".
        "mb_size, mb_level) values ('$UID','$msg_id','$from','$receiver',   ".
        "'$remail', '$subject', sysdate(), 2, 'Y', '$mb_attach', '$filename',".
        " $size, '$level_db')";

 if ($debug>0)
 {
  echo " $sql_insert";
  
 }
 $sth = dbquery($dbh,$sql_insert);
}

if ($debug>0)
 exit;

/* database close */
dbclose($dbh);

$EN_MSG_MAIL_SEND_OK = base64_encode($MSG_MAIL_SEND_OK);
if ($ckurl == "doublelayer")
{
 /* redirect */
 header("Location: error.php?action=refresh1_close&msg=$EN_MSG_MAIL_SEND_OK");
}
else
{
 /* redirect */
 header("Location: error.php?action=refresh2_close&msg=$EN_MSG_MAIL_SEND_OK"); <-746
}

?>

 


관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,291 명
  • 현재 강좌수 :  36,953 개
  • 현재 접속자 :  507 명