2017-11-02 5 views
0

http://nodeiterator.pl/메시지 필드가 비어 있지만 필수는 아니지만 PHPmailer는 메일을 보내지 않습니까?

메시지 필드가 비어 있지만 필수는 아니지만 필자의 php mailer 스크립트가 메일을 보내지 않는 이유는 무엇입니까? "나중에 다시 시도하십시오."라는 메시지가 나타납니다. 내가 뭘 놓치고 있니? 난 당신이 빈 몸으로 이메일을 보내 드릴 것입니다 기본적으로 PHPMail 생각하지 않습니다

$msg = ""; 
use PHPMailer\PHPMailer\PHPMailer; 
include_once "phpmailer/src/PHPMailer.php"; 
include_once "phpmailer/src/Exception.php"; 


if (isset($_POST['submit'])) { 
    $subject = $_POST['subject']; 
    $email = $_POST['email']; 
    $message = $_POST['message']; 

    if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != "") { 
     $file = "attachment/" . basename($_FILES['attachment']['name']); 
     move_uploaded_file($_FILES['attachment']['tmp_name'], $file); 
    } else 
     $file = ""; 

    $mail = new PHPMailer(); 



    $mail->addAddress('[email protected]'); 
    $mail->setFrom($email); 
    $mail->Subject = $subject; 
    $mail->isHTML(true); 
    $mail->Body = $message; 
    $mail->addAttachment($file); 

    if ($mail->send()) 
     $msg = "Your email has been sent, thank you!"; 
    else 
     $msg = "Please try again!"; 


} 
+0

if (empty ($ message)) $ message = "";와 같은 코드 줄을 추가하는 것은 어떨까요? – Lucarnosky

+0

내 대답을 확인하십시오 .. 쉬운 수정. –

답변

1

,하지만 당신은 갈 수 있습니다 :

내 스크립트입니다

$mail->AllowEmpty = true; 
+0

맞습니다. – Synchro

0

확인 오류가 반환 :

이 가
if(!$mail->Send()) { 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
} 

보통의 phpmailer 빈 몸을 허용하지 않습니다, 당신은 속성 012를 사용하여 강제해야한다

+0

메일러 오류 : 수신자 이메일 주소를 하나 이상 제공해야합니다. – Piotr