2012-07-16 7 views
3

나는이 오류 얻을 PHPMailer 클래스를 사용하여 이메일을 보내려고하면 : 당신이 설정하는 이후PHP 메일러 클래스 문제 : 빈 메시지 본문

<?php 

    include("class.phpmailer.php"); 

    $mail = new PHPMailer(); 
    $mail->IsSMTP(); 

    $mail->SMTPAuth = true; 

    $mail->SMTPSecure = "ssl"; 
    $mail->Host  = "rsb20.rhostbh.com"; 
    $mail->Port  = 465; 
    $mail->Username = "jobserreker+furrtexlab.com"; 
    $mail->Password = "12345678a"; 

    $mail->From  = "[email protected]"; 
    $mail->FromName = "Job Seeker"; 
    $mail->Subject = $_GET['subject']; 
    $mail->MsgHTML($_GET['msg']); 

    $mail->AddAddress($_GET['to'],"name to"); 
    $mail->IsHTML(false); 

    if(!$mail->Send()) 
    { 
     echo "Mailer Error: " . $mail->ErrorInfo; 

    }else{ 

     echo "Message sent!"; 
    } 
?> 
+0

언제든지 $ _GET [ 'msg']가 비어 있습니까? – unfrev

+1

$ mail-> MsgHTML을 사용하는 경우 ($ _ GET [ 'msg']); 그러나 $ mail-> IsHTML (거짓)이라고 말하십시오; 텍스트를 설정하기 위해 다른 속성을 사용하기로되어 있지 않습니까? 몸과 같은 속성? 아니면 $ _GET [ 'msg']가 비어 있습니까? –

+0

'echo '--->'할 수 있습니까? $ _GET [ 'msg']. '<---', $ _GET [ 'msg']'의 내용을 검사하기 위해서? – fsenart

답변

5

제럴드 Versluis의 말처럼, : 메일 서버 오류 : 빈 메시지 본문을 IsHTML()을 false로 설정하면 메일 본문을 설정하기 위해 -> Body 속성을 사용해야합니다.

$mail->Body = $_GET['msg']; 

조치를 수행하는 항목을 제출하려면 GET 대신 POST를 사용해야합니다.

+0

이것은 작동하지 않습니다. 일부 메시지는 그들 중 일부를 보냈습니다 응답을 얻으십시오 – Aan

+1

메시지를받을 때 var_dump ($ mail)를 추가하여 질문에 결과를 게시하십시오. 메시지를 barfs하는 것만으로 if (empty ($ this-> Body))를 수행하기 때문에, 당신이 생각하는 값으로 설정하지 않은 것 같아요. -> 몸). – MatsLindh

0

나는이 두 줄의 코드를 가지고 있지만 contents.html 파일이 없으므로 오류를 피하기 위해 하나를 만들어야했습니다.

//Read an HTML message body from an external file, convert referenced imagesto embedded, 
//convert HTML into a basic plain-text alternative body 
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__)); 

//Replace the plain text body with one created manually 
$mail->AltBody = 'This is a plain-text message body';`