When I send mail to a bad email address (such as an unknown user) with Groupwise or Outlook, the mail server at the destination will appropriately reply with an undeliverable error message. If I try the same thing with the script below, no error message is returned. Is there a header that I need to get these mail delivery errors to bounce back to me?
- - I hope this helps - -
(Complain to someone else if it doesn't)
Code:
<?php
print ("<html><head><title>Web Mailer</title></head><body>\n");
$to = array ("me@mydomain.com","spamjim@yahoo.com","spamjim@hotmail.com");
for ($n=0; $n < count($to); $n++)
{
$notice_text = "This is a multi-part message in MIME format.";
$plain_text = "This is the plain text message";
$html_text = "<html><head><title>no title needed</title></head><body>This is the HTML mail</body></html>";
$html_text = wordwrap($html_text, 72);
$plain_text = wordwrap($plain_text, 72);
$semi_rand = md5(time());
$mime_boundary = "==MULTIPART_BOUNDARY_$semi_rand";
$mime_boundary_header = chr(34) . $mime_boundary . chr(34);
$from = "me@mydomain.com";
$replies = "me@mydomain.com";
$subject = "This is the subject line";
$headers = "From: Me <$from>\n";
$headers .= "Reply-To: $replies\n";
$headers .= "X-Sender: $from\n";
$headers .= "X-Mailer: PHP4\n";
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: $from\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/alternative;\n";
$headers .= " boundary=";
$headers .= $mime_boundary_header;
$body = "$notice_text
--$mime_boundary
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
$plain_text
--$mime_boundary
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
$html_text
--$mime_boundary--";
if (@mail($to[$n], $subject, $body, $headers)) {
echo "$to[$n]<br>";
} else {
echo "<font color=red><b>FAIL:</b></font> $to[$n]<br>";
}
}
print ("</body></html>\n");
?>
- - I hope this helps - -
(Complain to someone else if it doesn't)