mail() building headers.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jasonrusso
Forum Newbie
Posts: 2
Joined: Fri Feb 20, 2004 11:42 am

mail() building headers.

Post by jasonrusso »

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);
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try using \r\n instead of just \n
jasonrusso
Forum Newbie
Posts: 2
Joined: Fri Feb 20, 2004 11:42 am

reply

Post by jasonrusso »

That didn't work. Emails are still bouncing to my root email account. i noticed the return-path says: <> . Wierd. Never had this problem in Perl. I'm not alone though, I see other users on my server using PHP mail() and there's are bouncing to the root too.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Which OS are you using?

Mac
Post Reply