0
<?php

require_once "vendor/autoload.php";

$mail = new PHPMailer;      
$mail->SMTPDebug = 0;                                   
$mail->isSMTP();                                         
$mail->Host = "localhost";    
$mail->SMTPAuth = false;                                  
$mail->Username = "[email protected]";                     
$mail->Password = "xxxxxxx";                              
$mail->SMTPSecure = "tls";                               
$mail->Port = 25;                                       
$mail->From = "[email protected]"    
$mail->FromName = "xxx";    
$mail->addAddress("[email protected]", "example");    
$mail->isHTML(true);
$mail->Subject = "Test";
$mail->Body = "<i>Helo</i>";
$mail->AltBody = "This is the plain text version of the email content";

if(!$mail->send()) 
{
    echo "Mailer Error: " . $mail->ErrorInfo;
} 
else 
{
    echo "Message has been sent successfully";
}

?>

Mailer Error:

SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: Missing internal data in the header. Message discarded. SMTP code: 550

granch
  • 225
  • 3
  • 12

1 Answers1

0

There's a great troubleshooter to PHP mail issues in the answer to a related question, PHP mail function doesn't complete sending of e-mail.

Among the details are some specifics on headers, which may help. Here are a couple:

Make sure all mail headers are supplied

Some spam software will reject mail if it is missing common headers such as "From" and "Reply-to":

$headers = array("From: [email protected]",
    "Reply-To: [email protected]",
    "X-Mailer: PHP/" . PHP_VERSION
);
$headers = implode("\r\n", $headers);
mail($to, $subject, $message, $headers);

Make sure mail headers have no syntax errors

Invalid headers are just as bad as having no headers. One incorrect character could be all it takes to derail your email. Double-check to make sure your syntax is correct as PHP will not catch these errors for you.

$headers = array("From [email protected]", // missing colon
    "Reply To: [email protected]",      // missing hyphen
    "X-Mailer: "PHP"/" . PHP_VERSION      // bad quotes
);
Tom Resing
  • 2,078
  • 1
  • 21
  • 28