I am trying to collect the bounced mails in one address. In the first part the code is sending to an invalid address and in the second part it is sending to one valid address to ensure mail has gone.
But nothing is returning ?? Here is the code.
$headers="";
$myname = "Me Myself";
$myemail = "safelisttest@rediffmail.com";
$contactname = "Mister Contact";
$contactemail = "asdf_4875_aas@hotmail.com"; //One invalid address
//$contactemail = "aweq487@rediffmail.com";
$message = "This mail should bounce back as posted to unknown address";
$subject = "SHOULD BOUNCE";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset = iso-8859-1\r\n";
$headers .= "From: ".$myname."<".$myemail.">\r\n";
$headers .= "To: ".$contactname."<".$contactemail.">\r\n";
$headers .= "Reply-To: ".$myname."<$myemail>\r\n";
$headers .= "Return-Path: ".$myname."<$myemail>\r\n";
$headers .= "Errors-to: ".$myname."<$myemail>\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";
echo $headers;
mail($contactemail, $subject, $message, $headers);
//Second part to send direct to a valid mail address.
$myname = "Me Myself";
$myemail = "safelisttest@rediffmail.com";
$contactname = "Mister Contact";
$contactemail = "plus2net@hotmail.com";
//$contactemail = "smo@localhost.com";
$message = "Directly posted so not to bounce";
$subject = "Direct Should NOT bounce";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset = iso-8859-1\r\n";
$headers .= "From: ".$myname."<".$myemail.">\r\n";
$headers .= "To: ".$contactname."<".$contactemail.">\r\n";
$headers .= "Reply-To: ".$myname."<$myemail>\r\n";
$headers .= "Return-Path: ".$myname."<$myemail>\r\n";
$headers .= "Errors-to: ".$myname."<$myemail>\r\n";
$headers .= "X-Priority: 1\r\n";
$headers .= "X-MSMail-Priority: High\r\n";
$headers .= "X-Mailer: Just My Server";
echo $headers;
mail($contactemail, $subject, $message, $headers);