2010-05-24 2 views
22

저는 PHP 스크립트에서 메일을 보내는 데 문제가 있습니다. 일부 데이터 :PHP 메일() 및/또는 PHPMailer 디버그

공유 만 제공 업체 패널을 호스팅, 더 SSH 액세스를 호스팅하지
  • PHP 버전 5.2.5
  • 작년 같은이
  • 호스팅 메일을 보내는 아무 문제가 없었다 사이트를 구축
  • 다음 코드에서 도메인이 "domain.com"이고 내 개인 주소가 "[email protected]"이라고 가정 해 봅시다. 최소한의 말을 이해할 수없는 어느

    Message sending failed Could not instantiate mail function.

    : 내가 무엇을 얻을 여기

    <?php 
    error_reporting(E_ALL); 
    ini_set("display_errors", 1); 
    
    $to = "[email protected]ain.com"; 
    $subject = "Hi"; 
    $body = "Test 1\nTest 2\nTest 3"; 
    $headers = 'From: [email protected]' . "\r\n" . 
        'errors-to: [email protected]' . "\r\n" . 
        'X-Mailer: PHP/' . phpversion(); 
    
    if (mail($to, $subject, $body, $headers)) { 
        echo("Message successfully sent"); 
    } else { 
        echo("Message sending failed"); 
    } 
    
    require('class.phpmailer.php'); 
    $message = "Hello world"; 
    $mail = new PHPMailer(); 
    $mail->CharSet = "UTF-8"; 
    $mail->AddAddress("[email protected]", "Agos"); 
    $mail->SetFrom("[email protected]","My Site"); 
    $mail->Subject = "Test Message"; 
    $mail->Body = $message; 
    $mail->Send(); 
    ?> 
    

    그리고 :

여기에 코드입니다. 적어도 더 의미있는 실수를 저지르기 위해 내가 할 수있는 일이 있습니까? 내 파일에 클래스의 코드가 표시되는 이유는 무엇입니까?

+0

치명적인 오류 : 라인 (20)에 /mailtest.php에서 찾을 수없는 클래스 'PHPMailer' ? 20 호선에 뭐가 들었 니? –

+0

@Mihai 20 번 라인은 $ mail = new PHPMailer(); – Agos

답변

37

class.phpmailer.php 파일이 손상된 것 같습니다. the latest version을 다운로드하고 다시 시도합니다. 난 항상 phpMailer의 SMTP 기능을 사용했습니다

:

$mail->IsSMTP(); 
$mail->Host = "localhost"; 

그리고 당신은 디버그 정보가 필요한 경우 :

$mail->SMTPDebug = 2; // enables SMTP debug information (for testing) 
         // 1 = errors and messages 
         // 2 = messages only 
+0

모든 것이 잘되었습니다. 감사! – Agos