2014-12-13 4 views
0

메일을 보내려는 경우 아래 코드를 입력하십시오. 나는 일어날 것을 알고있다. localhost에서는 작동하지만 라이브 서버에서는 작동하지 않습니다.PHP 메일 기능이 온라인 서버에서 작동하지 않습니다.

if (isset($_POST['test_mail'])){ 
          $to    = '[email protected]'; //put email address on which mail send 
          $subject  = "Newsletter";     //Put subject of mail here 
          $from  = '[email protected]';  //put email address from 
          //email body start 
          // $body .= file_get_contents('file/'.$filename.''); 
          $body  .= 'anio'; 
          // Always set content-type when sending HTML email 
          $headers = "MIME-Version: 1.0" . "\r\n"; 
          $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; 

          // More headers 
          $headers .= 'From: '.$from. "\r\n"; 

          //if you need to send cc mail then uncomment below line and change email address 
          //$headers .= 'Cc: [email protected]' . "\r\n"; 

         mail($to,$subject,$body,$headers); 

    } 
+0

귀하의 메일 서버를 구성하거나 php.ini 파일에서 잘못되지 않습니다. 로그를 확인하십시오. –

답변

0

서버의 MTA 로그를 확인하십시오. 또한 웹 서버 로그에 응답이있을 것입니다.

0

서버가 실제로 메일을 보낼 수 있는지 확인하기 위해 외부 데이터가 필요없는 간단한 mail() 스크립트로 테스트하십시오. 실패하면 서버 관리자에게 도움을 요청해야합니다.

1
try this.. 
<?php if (isset($_POST['test_mail'])){ 
    $host=$_SERVER['HTTP_HOST']; 
    $replyto="<no-reply >"; 
    $to ='[email protected]'; 
    $subject = "Newsletter"; 
    $from = '[email protected]'; 
    $headers = "From: \"Invoice\"<[email protected]$host>\n"; 
    $headers .= "Reply-To: ".$replyto."\r\n"; 
    $headers .= "MIME-Version: 1.0\r\n"; 
    $headers .= "Content-Type: multipart/mixed; boundary=\"abc"\"\r\n\r\n"; 
    $headers .= 'From: '.$from. "\r\n"; 
    $header .= "Content-Type:text/html; charset=\"iso-8859-1\"\n"; 
    $body = "This is a multi-part message in MIME format.\r\n"; 
    $body .= "Content-type:text/html; charset=iso-8859-1\r\n"; 
    $body .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; 
    $body  .= 'anio';       
    mail($to,$subject,$body,$headers); 
} 

?>

관련 문제