mail() building headers.
Posted: Fri Feb 20, 2004 11:42 am
I've been using PHP's mail() function in several of my programs. I didn't notice until recently that if an email is undeliverable it gets returned to my servers root mail account or root@localhost How do I get undeliverables to return to the email address in the mailheaders? Here's an example of my email headers:
$msg = "test";
$subject = "test";
$email = "me@mydomain.com";
$adminmailheaders = "From: $email\n";
$adminmailheaders .= "CC: $ccemail\n";
$adminmailheaders .= "BCC: $bccemail\n";
$adminmailheaders .= "Reply-To: $email\n";
$adminmailheaders .= "Return-Path: $email\n";
mail($email,$subject,$msg,$adminmailheaders);
$msg = "test";
$subject = "test";
$email = "me@mydomain.com";
$adminmailheaders = "From: $email\n";
$adminmailheaders .= "CC: $ccemail\n";
$adminmailheaders .= "BCC: $bccemail\n";
$adminmailheaders .= "Reply-To: $email\n";
$adminmailheaders .= "Return-Path: $email\n";
mail($email,$subject,$msg,$adminmailheaders);